From db331d8255c5e5d37dbe07883ab08fcd7ceca326 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Fri, 17 Oct 2025 11:53:24 -0600 Subject: [PATCH] change validateAcount --- src/persona/google.strategy.ts | 17 +++++++++++++---- src/persona/persona.service.ts | 6 ++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/persona/google.strategy.ts b/src/persona/google.strategy.ts index 65a87ae..0cd630a 100644 --- a/src/persona/google.strategy.ts +++ b/src/persona/google.strategy.ts @@ -37,14 +37,23 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { done: VerifyCallback, ): Promise { 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); diff --git a/src/persona/persona.service.ts b/src/persona/persona.service.ts index 865c325..7c0a3b9 100644 --- a/src/persona/persona.service.ts +++ b/src/persona/persona.service.ts @@ -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(),