Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 221 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"@nestjs/config": "^4.0.3",
"@nestjs/core": "^11.1.15",
"@nestjs/event-emitter": "^3.0.1",
"@nestjs/jwt": "^11.0.2",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.1.15",
"@nestjs/sequelize": "^11.0.1",
"@nestjs/swagger": "^11.2.6",
Expand All @@ -43,6 +45,8 @@
"helmet": "^8.1.0",
"nanoid": "^5.1.5",
"nestjs-pino": "^4.6.0",
"passport": "^0.7.0",
"passport-jwt": "^4.0.1",
"pg": "^8.20.0",
"pino-http": "^11.0.0",
"pino-pretty": "^13.1.3",
Expand All @@ -64,6 +68,7 @@
"@types/chance": "^1.1.7",
"@types/express": "^5.0.6",
"@types/node": "^22.15.0",
"@types/passport-jwt": "^4.0.1",
"@vitest/coverage-v8": "^3.2.4",
"chance": "^1.1.13",
"eslint": "^9.18.0",
Expand Down
28 changes: 20 additions & 8 deletions src/modules/auth/auth.guard.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import {
type CanActivate,
type ExecutionContext,
Injectable,
} from '@nestjs/common';
import { Injectable, type ExecutionContext } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { AuthGuard } from '@nestjs/passport';
import { IS_PUBLIC_KEY } from './decorators/public.decorator.js';

@Injectable()
export class AuthGuard implements CanActivate {
canActivate(_context: ExecutionContext): boolean {
return true;
export class JwtAuthGuard extends AuthGuard('jwt') {
constructor(private readonly reflector: Reflector) {
super();
}

canActivate(context: ExecutionContext) {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
context.getHandler(),
context.getClass(),
]);

if (isPublic) {
return true;
}

return super.canActivate(context);
}
}
Loading