Skip to content

Commit

Permalink
Support Bearer Tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Jan 1, 2022
1 parent 15743ed commit 81e10a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/auth/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export type AuthRequest = Request & {
export const useAuth: RequestHandler = NextHandler(
async (request: AuthRequest, response) => {
if (!request.headers.authorization) return NoPermission();
const auth = request.headers.authorization;
let auth = request.headers.authorization;

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

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

Expand Down

0 comments on commit 81e10a3

Please sign in to comment.