This commit is contained in:
2026-04-06 18:33:04 +03:30
parent 1160d81cdb
commit af71fb441b
7 changed files with 59 additions and 4 deletions
+9
View File
@@ -10,6 +10,7 @@ import { Reflector } from '@nestjs/core'
import { JwtService } from '@nestjs/jwt'
import { Request as ExpressRequest } from 'express'
import { IS_PUBLIC_KEY } from '../decorators/public.decorator'
import { IS_PUBLIC_WITH_TOKEN_KEY } from '../decorators/withToken.decorator'
import { ConsumerGuard } from './auth-consumer.guard'
import { PosGuard } from './auth-pos.guard'
@@ -43,6 +44,14 @@ export class JwtAuthGuard implements CanActivate {
if (!token) throw new UnauthorizedException('Missing access token')
const isPublicWithToken = this.reflector.getAllAndOverride<boolean>(
IS_PUBLIC_WITH_TOKEN_KEY,
[context.getHandler(), context.getClass()],
)
if (isPublicWithToken) {
return true
}
try {
this.jwt.verify(token, {
secret: process.env.JWT_SECRET,