se agregaron cambios de seguridad

This commit is contained in:
2025-09-12 12:38:15 -06:00
parent 8c6502d82c
commit 55e64da38d
4 changed files with 34 additions and 3 deletions
+6 -1
View File
@@ -16,6 +16,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
clientSecret: config.get<string>('GOOGLE_CLIENT_SECRET'),
callbackURL: config.get<string>('GOOGLE_CALLBACK_URL'),
scope: ['email', 'profile'],
failureRedirect: `${process.env.FRONTEND_URL}?error=oauth_failed`,
});
}
@@ -25,15 +26,19 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
profile: any,
done: VerifyCallback,
): Promise<any> {
try{
const { emails } = profile;
const email = emails[0].value;
const user = await this.authService.validateGoogleUser(email);
if (!user) {
throw new UnauthorizedException('Usuario no registrado en el sistema');
done(null, false);
}
done(null, user);
}catch(err){
done(null, false);
}
}
}