Added some logs

This commit is contained in:
Gabriel Rosa
2023-01-30 16:35:05 -03:00
parent 642bf462ad
commit 161d1fa05d
+7 -1
View File
@@ -236,6 +236,7 @@ export class AuthController {
@Get('oauth/google')
@UseGuards(AuthGuard('google-login'))
googleOauth() {
this.logger.info('/oauth/google');
return true;
}
@@ -244,7 +245,10 @@ export class AuthController {
@Redirect()
async googleOauthCallback(@Req() req) {
const { url, email, token, language = 'pt-br' } = await this.callback(req);
if (url.searchParams.get('error')) return { url: url.href };
if (url.searchParams.get('error')) {
this.logger.error('/oauth/google - ERROR');
return { url: url.href };
}
await this.authClient
.oauthSignIn({
@@ -252,9 +256,11 @@ export class AuthController {
token,
})
.then(({ session }) => {
this.logger.info('/oauth/google - SUCESS');
url.searchParams.set('session', session);
})
.catch((err) => {
this.logger.error('/oauth/google - ERROR');
let error = OauthErrors.INVALID_CREDENTIALS[language].error;
let error_description =
OauthErrors.INVALID_CREDENTIALS[language].error_description;