Skip to content

Commit

Permalink
remove auth type check in session handler
Browse files Browse the repository at this point in the history
  • Loading branch information
skovati committed Jan 11, 2024
1 parent 94d8818 commit 59f919f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/packages/auth/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,11 @@ export async function login(username: string, password: string): Promise<AuthRes
}

export async function session(authorizationHeader: string | undefined): Promise<SessionResponse> {
const { AUTH_TYPE } = getEnv();
const { jwtErrorMessage, jwtPayload } = decodeJwt(authorizationHeader);

if (AUTH_TYPE === 'none') {
return { message: `Authentication is disabled`, success: true };
if (jwtPayload) {
return { message: 'Token is valid', success: true };
} else {
const { jwtErrorMessage, jwtPayload } = decodeJwt(authorizationHeader);

if (jwtPayload) {
return { message: 'Token is valid', success: true };
} else {
return { message: jwtErrorMessage, success: false };
}
return { message: jwtErrorMessage, success: false };
}
}

0 comments on commit 59f919f

Please sign in to comment.