diff options
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs')
-rw-r--r-- | Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs b/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs index 8115bee..1f59342 100644 --- a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs +++ b/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs @@ -1,9 +1,7 @@ namespace LibMatrix.HomeserverEmulator.Services; -public class TokenService(IHttpContextAccessor accessor) { - public string? GetAccessToken() { - var ctx = accessor.HttpContext; - if (ctx is null) return null; +public class TokenService{ + public string? GetAccessToken(HttpContext ctx) { //qry if (ctx.Request.Query.TryGetValue("access_token", out var token)) { return token; @@ -11,16 +9,14 @@ public class TokenService(IHttpContextAccessor accessor) { //header if (ctx.Request.Headers.TryGetValue("Authorization", out var auth)) { var parts = auth.ToString().Split(' '); - if (parts.Length == 2 && parts[0] == "Bearer") { + if (parts is ["Bearer", _]) { return parts[1]; } } return null; } - public string? GenerateServerName() { - var ctx = accessor.HttpContext; - if (ctx is null) return null; + public string? GenerateServerName(HttpContext ctx) { return ctx.Request.Host.ToString(); } } \ No newline at end of file |