change validateAcount
This commit is contained in:
@@ -37,14 +37,23 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
|
|||||||
done: VerifyCallback,
|
done: VerifyCallback,
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const email = profile.emails?.[0]?.value;
|
const email = profile.emails?.[0]?.value || '';
|
||||||
const name = profile.name?.givenName || '';
|
|
||||||
const apellidoP = profile.name?.familyName || '';
|
// 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({
|
const user = await this.personaService.validateOrCreateGoogleUser({
|
||||||
email,
|
email,
|
||||||
nombre: name,
|
nombre,
|
||||||
apellidoP,
|
apellidoP,
|
||||||
|
apellidoM,
|
||||||
|
numeroIdentificar,
|
||||||
});
|
});
|
||||||
|
|
||||||
done(null, user);
|
done(null, user);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export class PersonaService {
|
|||||||
email: string;
|
email: string;
|
||||||
nombre: string;
|
nombre: string;
|
||||||
apellidoP: string;
|
apellidoP: string;
|
||||||
|
apellidoM: string;
|
||||||
|
numeroIdentificar: string;
|
||||||
}) {
|
}) {
|
||||||
let persona = await this.findByEmail(data.email);
|
let persona = await this.findByEmail(data.email);
|
||||||
|
|
||||||
@@ -43,7 +45,7 @@ export class PersonaService {
|
|||||||
persona = await this.create({
|
persona = await this.create({
|
||||||
nombre: data.nombre || '',
|
nombre: data.nombre || '',
|
||||||
apellidoP: data.apellidoP || '',
|
apellidoP: data.apellidoP || '',
|
||||||
apellidoM: '',
|
apellidoM: data.apellidoM || '',
|
||||||
password: '',
|
password: '',
|
||||||
passwordTem: '',
|
passwordTem: '',
|
||||||
fechaPasswordTem: new Date(),
|
fechaPasswordTem: new Date(),
|
||||||
@@ -51,7 +53,7 @@ export class PersonaService {
|
|||||||
carreraAds: '',
|
carreraAds: '',
|
||||||
cantidadCuenta: 0,
|
cantidadCuenta: 0,
|
||||||
usuario: '',
|
usuario: '',
|
||||||
numeroIdentificar: '',
|
numeroIdentificar: data.numeroIdentificar || '',
|
||||||
tipoUsuario: '',
|
tipoUsuario: '',
|
||||||
correoEnviado: false,
|
correoEnviado: false,
|
||||||
fechaRegistro: new Date(),
|
fechaRegistro: new Date(),
|
||||||
|
|||||||
Reference in New Issue
Block a user