From e4e13a896f02e73aa2b99e18f82e3269e09a1659 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Mon, 4 Nov 2024 21:19:25 -0500 Subject: [PATCH] fix token bug? --- src/ws/events/user/handlers/hi.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ws/events/user/handlers/hi.ts b/src/ws/events/user/handlers/hi.ts index 33bf291..ee15a63 100644 --- a/src/ws/events/user/handlers/hi.ts +++ b/src/ws/events/user/handlers/hi.ts @@ -52,18 +52,20 @@ export const hi: ServerEventListener<"hi"> = { if (config.tokenAuth !== "none") { if (typeof msg.token !== "string") { - socket.gateway.hasSentToken = true; - // Get a saved token token = await getToken(socket.getUserID()); + + // Does it exist? if (typeof token !== "string") { // Generate a new one token = await createToken( socket.getUserID(), socket.gateway ); + socket.gateway.isTokenValid = true; + // Does it exist? (again) if (typeof token !== "string") { logger.warn( `Unable to generate token for user ${socket.getUserID()}` @@ -73,6 +75,8 @@ export const hi: ServerEventListener<"hi"> = { } } } else { + socket.gateway.hasSentToken = true; + // Validate the token const valid = await validateToken( socket.getUserID(),