From 37b97d65c0a5262539a5de560e911048166b8bba Mon Sep 17 00:00:00 2001 From: "Emma [it/its]@Rory&" Date: Fri, 5 Apr 2024 18:58:32 +0200 Subject: Fix homeserver resolution, rewrite homeserver initialisation, HSE work --- Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs') 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(); } -- cgit 1.4.1