change validateAcount

This commit is contained in:
2025-10-17 11:53:24 -06:00
parent 05129381be
commit db331d8255
2 changed files with 17 additions and 6 deletions
+13 -4
View File
@@ -37,14 +37,23 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
done: VerifyCallback,
): Promise<any> {
try {
const email = profile.emails?.[0]?.value;
const name = profile.name?.givenName || '';
const apellidoP = profile.name?.familyName || '';
const email = profile.emails?.[0]?.value || '';
// Separar apellidos
const apellidos = (profile.name?.familyName || '').trim().split(' ');
const apellidoP = apellidos[0] || '';
const apellidoM = apellidos[1] || '';
const nombre = apellidos.slice(2).join(' ') || '';
// Número identificador del correo
const numeroIdentificar = email.split('@')[0];
const user = await this.personaService.validateOrCreateGoogleUser({
email,
nombre: name,
nombre,
apellidoP,
apellidoM,
numeroIdentificar,
});
done(null, user);
+4 -2
View File
@@ -36,6 +36,8 @@ export class PersonaService {
email: string;
nombre: string;
apellidoP: string;
apellidoM: string;
numeroIdentificar: string;
}) {
let persona = await this.findByEmail(data.email);
@@ -43,7 +45,7 @@ export class PersonaService {
persona = await this.create({
nombre: data.nombre || '',
apellidoP: data.apellidoP || '',
apellidoM: '',
apellidoM: data.apellidoM || '',
password: '',
passwordTem: '',
fechaPasswordTem: new Date(),
@@ -51,7 +53,7 @@ export class PersonaService {
carreraAds: '',
cantidadCuenta: 0,
usuario: '',
numeroIdentificar: '',
numeroIdentificar: data.numeroIdentificar || '',
tipoUsuario: '',
correoEnviado: false,
fechaRegistro: new Date(),