refs #6397 emailValidation #1941
|
@ -1,3 +1,5 @@
|
||||||
|
const {error} = require('fancy-log');
|
||||||
|
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
Self.remoteMethod('createWithUser', {
|
Self.remoteMethod('createWithUser', {
|
||||||
description: 'Creates both client and its web account',
|
description: 'Creates both client and its web account',
|
||||||
|
@ -29,12 +31,15 @@ module.exports = function(Self) {
|
||||||
myOptions.transaction = tx;
|
myOptions.transaction = tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.email) {
|
||||||
|
|||||||
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
alexm
commented
Esto se puede refactorizar y dejar sin if else Esto se puede refactorizar y dejar sin if else
|
|||||||
const user = {
|
const user = {
|
||||||
carlossa marked this conversation as resolved
Outdated
alexm
commented
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)
|
|||||||
name: data.userName,
|
name: data.userName,
|
||||||
email: firstEmail,
|
email: firstEmail,
|
||||||
password: String(Math.random() * 100000000000000)
|
password: String(Math.random() * 100000000000000)
|
||||||
};
|
};
|
||||||
|
} else
|
||||||
|
throw error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const account = await models.VnUser.create(user, myOptions);
|
const account = await models.VnUser.create(user, myOptions);
|
||||||
|
|
Loading…
Reference in New Issue
@alexm valorares la opcio de posar-ho en back/models/vn-user.js com a una validacio nativa?
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