diff options
author | Emma [it/its]@Rory& <root@rory.gay> | 2024-03-05 11:19:52 +0100 |
---|---|---|
committer | Emma [it/its]@Rory& <root@rory.gay> | 2024-03-05 11:19:52 +0100 |
commit | f41b6e5ec431c88bc1d94e4832d8ba49ddc42004 (patch) | |
tree | 503be94f5036f7cc221846c1eabf7c5edd107f1a /Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs | |
parent | Unknown changes (diff) | |
download | LibMatrix-f41b6e5ec431c88bc1d94e4832d8ba49ddc42004.tar.xz |
HomeserverEmulator work
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 |