FIX: logging oauth error

This commit is contained in:
Gabriel Rosa
2023-12-07 17:27:30 -03:00
parent 695fac97e9
commit 98759b1cf5
2 changed files with 9 additions and 6 deletions
+5 -3
View File
@@ -79,11 +79,13 @@ export class AuthenticationGuard
request,
mustBeAuthenticated: boolean,
): RequestUser | false {
const accessToken = request.get('Authorization');
const accessToken: string = request.get('Authorization');
let accessTokenPayload: RequestUser;
this.logger.info(`accessToken: ${accessToken}`)
this.logger.info(`mustBeAuthenticated: ${mustBeAuthenticated}`);
this.logger.info(
`accessToken (first 5 chars): ${accessToken?.slice(0, 5)}`,
);
// If the user isn't authenticated, an error will occurr anywhere here.
// Fancy error avoidance isn't performed by purpose, such as avoiding to access null values.
try {
+4 -3
View File
@@ -327,7 +327,8 @@ export class AuthController {
language = 'pt-br',
} = await this.callback(req, 'magalu-id');
if (url.searchParams.get('error')) {
this.logger.error('/oauth/magalu-id - ERROR');
this.logger.error('/oauth/magalu-id/callback - ERROR');
this.logger.error(url.searchParams.get('error'));
return { url: url.href };
}
@@ -338,11 +339,11 @@ export class AuthController {
refreshToken,
})
.then(({ session }) => {
this.logger.info('/oauth/magalu-id - SUCESS');
this.logger.info('/oauth/magalu-id/callback - SUCESS');
url.searchParams.set('session', session);
})
.catch((err) => {
this.logger.error('/oauth/magalu-id - ERROR');
this.logger.error('/oauth/magalu-id/callback - LOGIN ERROR');
let error = OauthErrors.INVALID_CREDENTIALS[language].error;
let error_description =
OauthErrors.INVALID_CREDENTIALS[language].error_description;