first commit
This commit is contained in:
14
apps/api-gateway/src/auth-token.ts
Normal file
14
apps/api-gateway/src/auth-token.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
export function extractBearerToken(authorization?: string): string {
|
||||
if (!authorization?.startsWith('Bearer ')) {
|
||||
throw new UnauthorizedException('Не передан токен доступа');
|
||||
}
|
||||
|
||||
const token = authorization.slice('Bearer '.length).trim();
|
||||
if (!token) {
|
||||
throw new UnauthorizedException('Не передан токен доступа');
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
Reference in New Issue
Block a user