From 05129381beda3b50370820fc975fda382729d880 Mon Sep 17 00:00:00 2001 From: IO420 <320154041@pcpuma.acatlan.unam.mx> Date: Fri, 17 Oct 2025 11:20:20 -0600 Subject: [PATCH] added new formater to save --- src/persona/persona.controller.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/persona/persona.controller.ts b/src/persona/persona.controller.ts index fc4d1bb..263319f 100644 --- a/src/persona/persona.controller.ts +++ b/src/persona/persona.controller.ts @@ -28,16 +28,20 @@ export class PersonaController { if (!googleUser) { return res.redirect(`${process.env.FRONTEND_URL}?error=oauth_failed`); } + // Separar apellidos + const apellidos = (googleUser.apellido || '').trim().split(' '); + const apellidoP = apellidos[0] || ''; + const apellidoM = apellidos.slice(1).join(' ') || ''; + + const numeroIdentificar = googleUser.email.split('@')[0]; - // Buscar en la base de datos si ya existe let persona = await this.personaService.findByEmail(googleUser.email); if (!persona) { - // Si no existe, crear nueva persona con los datos de Google persona = await this.personaService.create({ nombre: googleUser.nombre || '', - apellidoP: googleUser.apellidoP || '', - apellidoM: '', // Google no da este dato + apellidoP, + apellidoM, password: '', // vacĂ­o porque es login OAuth passwordTem: '', fechaPasswordTem: new Date(), @@ -45,7 +49,7 @@ export class PersonaController { carreraAds: '', cantidadCuenta: 0, usuario: '', - numeroIdentificar: '', + numeroIdentificar, tipoUsuario: '', correoEnviado: false, fechaRegistro: new Date(),