fix token bug?

This commit is contained in:
Hri7566 2024-11-04 21:19:25 -05:00
parent a7e4902b7e
commit e4e13a896f
1 changed files with 6 additions and 2 deletions

View File

@ -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(),