trying to make api-docs public
This commit is contained in:
parent
6cdbe702fc
commit
1210016142
@ -11,7 +11,7 @@ export class AuthGuard implements CanActivate {
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly reflector: Reflector,
|
||||
private readonly configService: ConfigService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async canActivate(context: ExecutionContext): Promise<boolean> {
|
||||
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
|
||||
@ -21,6 +21,9 @@ export class AuthGuard implements CanActivate {
|
||||
if (isPublic) return true;
|
||||
|
||||
const request = context.switchToHttp().getRequest<Request>();
|
||||
if (request.path.startsWith('/api-docs') || request.path.startsWith('/api-json')) {
|
||||
return true;
|
||||
}
|
||||
const authHeader = request.headers['authorization'] as string | undefined;
|
||||
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||
@ -30,7 +33,7 @@ export class AuthGuard implements CanActivate {
|
||||
const token = authHeader.split(' ')[1];
|
||||
try {
|
||||
const payload = await this.jwtService.verifyAsync(token, {
|
||||
secret: this.configService.get<string>('jwt.accessSecret'), // ✅ corrige ici
|
||||
secret: this.configService.get<string>('jwt.accessSecret'),
|
||||
});
|
||||
request.user = payload;
|
||||
return true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user