CreateUserProfile: save first email on account table and all emails on client table

This commit is contained in:
Vicente Falco 2017-09-20 12:15:38 +02:00
parent e76f1d74f9
commit 6c3ac042f1
1 changed files with 7 additions and 5 deletions

View File

@ -2,7 +2,7 @@ var app = require('../../../server/server');
module.exports = function(Client){
Client.remoteMethod('createUserProfile', {
description: `Creates both client it's web account`,
description: 'Creates both client and its web account',
accepts: {
arg: 'data',
type: 'object',
@ -19,8 +19,10 @@ module.exports = function(Client){
});
Client.createUserProfile = (data, callback) => {
let firstEmail = data.email.split(',')[0];
let user = {
name: data.userName,
email: firstEmail,
password: parseInt(Math.random() * 100000000000000)
};
@ -33,10 +35,10 @@ module.exports = function(Client){
let client = {
name: data.name,
email: data.email,
fi: data.fi,
socialName: data.socialName,
id: account.id
id: account.id,
email: data.email
};
Client.create(client, {transaction}, (err, client) => {