se agregaron cambios de seguridad
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user