about summary refs log tree commit diff
path: root/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2024-04-05 18:58:32 +0200
committerEmma [it/its]@Rory& <root@rory.gay>2024-04-05 18:58:32 +0200
commit37b97d65c0a5262539a5de560e911048166b8bba (patch)
treef704a9c703b0ec47122a460576e151e0cb06fdc6 /Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs
parentFix merge conficts between machines (diff)
downloadLibMatrix-37b97d65c0a5262539a5de560e911048166b8bba.tar.xz
Fix homeserver resolution, rewrite homeserver initialisation, HSE work
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs')
-rw-r--r--Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs b/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs

index 1f59342..cf79aae 100644 --- a/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs +++ b/Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs
@@ -1,7 +1,7 @@ namespace LibMatrix.HomeserverEmulator.Services; public class TokenService{ - public string? GetAccessToken(HttpContext ctx) { + public string? GetAccessTokenOrNull(HttpContext ctx) { //qry if (ctx.Request.Query.TryGetValue("access_token", out var token)) { return token; @@ -16,6 +16,13 @@ public class TokenService{ return null; } + public string GetAccessToken(HttpContext ctx) { + return GetAccessTokenOrNull(ctx) ?? throw new MatrixException() { + ErrorCode = MatrixException.ErrorCodes.M_UNKNOWN_TOKEN, + Error = "Missing token" + }; + } + public string? GenerateServerName(HttpContext ctx) { return ctx.Request.Host.ToString(); }