From 358442970b6a0cbd8ab614fbe5d79572e608a320 Mon Sep 17 00:00:00 2001 From: Marcus Longmuir Date: Fri, 19 Apr 2024 13:07:08 +0100 Subject: [PATCH] Fix ExampleEnforcingUserAuthenticator --- .../ExampleEnforcingUserAuthenticator.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/example/server/src/example-character-customisation-auth/ExampleEnforcingUserAuthenticator.ts b/example/server/src/example-character-customisation-auth/ExampleEnforcingUserAuthenticator.ts index 6fafcb7d..f69e31b3 100644 --- a/example/server/src/example-character-customisation-auth/ExampleEnforcingUserAuthenticator.ts +++ b/example/server/src/example-character-customisation-auth/ExampleEnforcingUserAuthenticator.ts @@ -93,6 +93,8 @@ export class ExampleEnforcingUserAuthenticator { if (foundCharacter) { resultCharacterDescription = foundCharacter; } + } + if (resultPermissions.allowUsername && req.query.username) { resultUsername = req.query.username as string; } @@ -237,6 +239,19 @@ export class ExampleEnforcingUserAuthenticator { return user.userData; } + public getClientIdForSessionToken(sessionToken: string): { id: number } | null { + const user = this.userBySessionToken.get(sessionToken); + if (!user) { + console.error("getClientIdForSessionToken - unknown session"); + return null; + } + if (user.clientId === null) { + console.error("getClientIdForSessionToken - client not connected"); + return null; + } + return { id: user.clientId }; + } + public onClientUserIdentityUpdate( clientId: number, newUserIdentity: UserIdentity,