🐛 fix: NeedAuth bug

This commit is contained in:
秦秋旭 2023-02-23 17:34:04 +08:00
parent a863806111
commit 5bbefbcf4a
2 changed files with 2 additions and 2 deletions

View File

@ -13,5 +13,5 @@ export function NeedAuth(needAuth = true) {
ApiUnauthorizedResponse({ description: 'Unauthorized' }), ApiUnauthorizedResponse({ description: 'Unauthorized' }),
) )
} }
return new Function() return applyDecorators(SetMetadata(NEED_AUTH_KEY, needAuth))
} }

View File

@ -16,8 +16,8 @@ export class JwtAuthGuard extends AuthGuard('jwt') {
canActivate(context: ExecutionContext) { canActivate(context: ExecutionContext) {
const needAuth = this.reflector.getAllAndOverride<boolean>(NEED_AUTH_KEY, [ const needAuth = this.reflector.getAllAndOverride<boolean>(NEED_AUTH_KEY, [
context.getClass(),
context.getHandler(), context.getHandler(),
context.getClass(),
]) ])
if (needAuth) { if (needAuth) {
return super.canActivate(context) return super.canActivate(context)