refs #6397 emailValidation #1941

Merged
carlossa merged 13 commits from 6397-emailValidation into dev 2024-02-01 17:45:54 +00:00
2 changed files with 8 additions and 6 deletions
Showing only changes of commit 7cb7c7dace - Show all commits

View File

@ -336,5 +336,6 @@
"Incorrect pin": "Pin incorrecto.", "Incorrect pin": "Pin incorrecto.",
"You already have the mailAlias": "Ya tienes este alias de correo", "You already have the mailAlias": "Ya tienes este alias de correo",
"The alias cant be modified": "Este alias de correo no puede ser modificado", "The alias cant be modified": "Este alias de correo no puede ser modificado",
"No tickets to invoice": "No hay tickets para facturar" "No tickets to invoice": "No hay tickets para facturar",
"An email is necessary": "An email is necessary"
carlossa marked this conversation as resolved Outdated
Outdated
Review

Falta traducir

Falta traducir
Outdated
Review

Falta traducir

Falta traducir
} }

View File

@ -1,4 +1,4 @@
const {error} = require('fancy-log'); const UserError = require('vn-loopback/util/user-error');
module.exports = function(Self) { module.exports = function(Self) {
Self.remoteMethod('createWithUser', { Self.remoteMethod('createWithUser', {
@ -31,15 +31,16 @@ module.exports = function(Self) {
myOptions.transaction = tx; myOptions.transaction = tx;
} }
let user;
Review

@alexm valorares la opcio de posar-ho en back/models/vn-user.js com a una validacio nativa?

@alexm valorares la opcio de posar-ho en back/models/vn-user.js com a una validacio nativa?
Review

Per mi si, pero hi hauria que mirar els nulls que hi hajen com se comporta la restriccio, pq segurament qualsevol canvi en el model fallara

Per mi si, pero hi hauria que mirar els nulls que hi hajen com se comporta la restriccio, pq segurament qualsevol canvi en el model fallara
if (data.email) { if (data.email) {
carlossa marked this conversation as resolved Outdated
Outdated
Review

Esto se puede refactorizar y dejar sin if else

Esto se puede refactorizar y dejar sin if else
const firstEmail = data.email ? data.email.split(',')[0] : null; const firstEmail = data.email ? data.email.split(',')[0] : null;
carlossa marked this conversation as resolved Outdated
Outdated
Review

Aqui como este codigo siempre va a tener data.email se puede quitar el hacer ? : (if else)

Aqui como este codigo siempre va a tener data.email se puede quitar el hacer ? : (if else)
const user = { user = {
name: data.userName, name: data.userName,
email: firstEmail, email: firstEmail,
password: String(Math.random() * 100000000000000) password: String(Math.random() * 100000000000000)
}; };
} else } else
throw error; throw new UserError(`An email is necessary`);
try { try {
const account = await models.VnUser.create(user, myOptions); const account = await models.VnUser.create(user, myOptions);