Skip to content

Commit

Permalink
Update Bearer Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Jan 1, 2022
1 parent f53cc23 commit 7314756
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/auth/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ export const useAuth: RequestHandler = NextHandler(
if (!request.headers.authorization) return NoPermission();
let auth = request.headers.authorization;

if (auth.toLowerCase().startsWith('Bearer ')) {
auth = auth.slice(0, Math.max(0, 'Bearer '.length));
if (auth.toLowerCase().startsWith('bearer ')) {
auth = auth.slice('Bearer '.length);
}

log.debug('Validating ' + auth);

const decoded = decode(auth) as { account: string; value: number };

if (!decoded) return NoPermission();
Expand Down

0 comments on commit 7314756

Please sign in to comment.