File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change 11import { ConfigService } from '@nestjs/config' ;
2- import { Injectable , Logger } from '@nestjs/common' ;
2+ import { Injectable } from '@nestjs/common' ;
33import { PassportStrategy } from '@nestjs/passport' ;
44
55import { ExtractJwt , Strategy } from 'passport-jwt' ;
@@ -9,8 +9,6 @@ import { JwtPayload } from '../types';
99
1010@Injectable ( )
1111export class JwtStrategy extends PassportStrategy ( Strategy ) {
12- private readonly logger = new Logger ( JwtStrategy . name ) ;
13-
1412 constructor ( private readonly configService : ConfigService ) {
1513 const secret = configService . getOrThrow < string > ( JWT_ACCESS_TOKEN_SECRET ) ;
1614 super ( {
@@ -21,7 +19,6 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
2119 }
2220
2321 async validate ( payload : JwtPayload ) {
24- this . logger . log ( `Validating JWT token: ${ JSON . stringify ( payload ) } ` ) ;
2522 return { id : payload . sub , email : payload . email } ;
2623 }
2724}
Original file line number Diff line number Diff line change 88 ParseUUIDPipe ,
99 Logger ,
1010 UseGuards ,
11+ UnauthorizedException ,
1112} from '@nestjs/common' ;
1213
1314import { JwtAuthGuard } from '@src/auth/guards' ;
@@ -30,7 +31,7 @@ export class WorkoutsController {
3031 ) {
3132 if ( ! userId ) {
3233 this . logger . error ( ResponseMessages . User . IdNotFound , userId ) ;
33- throw new Error ( ResponseMessages . User . IdNotFound ) ;
34+ throw new UnauthorizedException ( ResponseMessages . User . IdNotFound ) ;
3435 }
3536 return await this . workoutsService . create ( CreateWorkoutDto , userId ) ;
3637 }
@@ -40,7 +41,7 @@ export class WorkoutsController {
4041 async findAll ( @CurrentUser ( 'id' ) userId : string ) {
4142 if ( ! userId ) {
4243 this . logger . error ( ResponseMessages . User . IdNotFound , userId ) ;
43- throw new Error ( ResponseMessages . User . IdNotFound ) ;
44+ throw new UnauthorizedException ( ResponseMessages . User . IdNotFound ) ;
4445 }
4546 return await this . workoutsService . findAll ( userId ) ;
4647 }
You can’t perform that action at this time.
0 commit comments