modified againd google auth
This commit is contained in:
@@ -7,18 +7,27 @@ export class GoogleAuthGuard extends AuthGuard('google') {
|
||||
const req = context.switchToHttp().getRequest();
|
||||
const res = context.switchToHttp().getResponse();
|
||||
|
||||
// Si hay info (por ejemplo, Google retorna ?error=access_denied)
|
||||
if (info) {
|
||||
// Solo redirigir si hay info Y no hay user
|
||||
if (info && !user) {
|
||||
return res.redirect(
|
||||
`${process.env.FRONTEND_URL}/oauth-callback?error=${info.message || info}`,
|
||||
);
|
||||
}
|
||||
|
||||
// Si no hay usuario ni error, permitimos que el controller maneje
|
||||
if (!user) {
|
||||
return null;
|
||||
// Si hay error de validación en validate()
|
||||
if (err) {
|
||||
return res.redirect(
|
||||
`${process.env.FRONTEND_URL}/oauth-callback?error=${err.message || 'oauth_failed'}`,
|
||||
);
|
||||
}
|
||||
|
||||
return user;
|
||||
// Si no hay usuario (pero sin info), redirigimos con error
|
||||
if (!user) {
|
||||
return res.redirect(
|
||||
`${process.env.FRONTEND_URL}/oauth-callback?error=oauth_failed`,
|
||||
);
|
||||
}
|
||||
|
||||
return user; // login exitoso
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user