Skip to content

Commit dd89255

Browse files
committed
Add logging for JWT authentication and session retrieval
1 parent 1b676e6 commit dd89255

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/core/auth/_strategies/jwt.strategy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { JwtPayload } from 'jsonwebtoken';
99

1010
@Injectable()
1111
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
12+
protected logger: Logger;
13+
1214
constructor(
1315
private readonly auth: AuthService,
1416
config: ConfigService,
@@ -27,7 +29,7 @@ export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
2729
payload: JwtPayload & { identity: AgentType },
2830
done: VerifiedCallback,
2931
): Promise<void> {
30-
Logger.verbose(`Atempt to authenticate with JTI: <${payload.jti}>`, JwtStrategy.name);
32+
this.logger.verbose(`Atempt to authenticate with JTI: <${payload.jti}>`, JwtStrategy.name);
3133
if (!payload?.identity) return done(new UnauthorizedException(), false);
3234
const user = await this.auth.verifyIdentity(payload);
3335

src/core/auth/auth.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export class AuthController extends AbstractController {
3737
@UseGuards(AuthGuard('jwt'))
3838
@ApiOperation({ summary: 'Récupération de la session en cours' })
3939
public async session(@Res() res: Response, @ReqIdentity() identity: AgentType): Promise<Response> {
40+
this.logger.debug(`Session request for ${identity.id} (${identity.email})`);
4041
const user = await this.service.getSessionData(identity);
42+
this.logger.debug(`Session data delivered for ${identity.id} (${identity.email}) with ${JSON.stringify(user)}`);
4143
return res.status(HttpStatus.OK).json({
4244
user: {
4345
...omit(user, ['security']),

0 commit comments

Comments
 (0)