mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
16 lines
352 B
TypeScript
16 lines
352 B
TypeScript
import type { HttpContext } from '@adonisjs/core/http';
|
|
|
|
export function getTokenFromHeader(ctx: HttpContext): string | null {
|
|
const authHeader = ctx.request.header('authorization');
|
|
if (!authHeader) {
|
|
return null;
|
|
}
|
|
|
|
const parts = authHeader.split(' ');
|
|
if (parts.length !== 2 || parts[0] !== 'Bearer') {
|
|
return null;
|
|
}
|
|
|
|
return parts[1];
|
|
}
|