change validateAcount
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user