mirror of
https://github.com/dadosfera/maestro.git
synced 2026-08-31 19:58:21 +00:00
FIX: logging errors only if auth is required
This commit is contained in:
committed by
arthur simas
parent
17d629b430
commit
0eef0713df
@@ -63,7 +63,7 @@ export class AuthenticationGuard
|
||||
);
|
||||
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
const accessToken = this.verifyToken(request);
|
||||
const accessToken = this.verifyToken(request, mustBeAuthenticated);
|
||||
|
||||
if (!accessToken) {
|
||||
// couldn't load valid token
|
||||
@@ -96,7 +96,7 @@ export class AuthenticationGuard
|
||||
return true;
|
||||
}
|
||||
|
||||
private verifyToken(request) {
|
||||
private verifyToken(request, mustBeAuthenticated: boolean) {
|
||||
const accessToken = request.get('Authorization');
|
||||
let accessTokenPayload;
|
||||
|
||||
@@ -123,8 +123,8 @@ export class AuthenticationGuard
|
||||
jwt.verify(accessToken, pemValue);
|
||||
accessTokenPayload = accessTokenDecoded.payload;
|
||||
} catch (err) {
|
||||
// only log if it's not a health check request
|
||||
if (`${request.method} ${request.route.path}` !== 'GET /health') {
|
||||
// log errors if authentication is required
|
||||
if (mustBeAuthenticated) {
|
||||
this.logger.log('Unable to verify duc access token\n' + err.stack);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user