diff options
Diffstat (limited to 'Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs')
-rw-r--r-- | Tests/LibMatrix.HomeserverEmulator/Services/TokenService.cs | 9 |
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(); } |