1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00
planka/server/api/controllers/users/create.js

42 lines
690 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
const Errors = {
USER_EXIST: {
conflict: 'User is already exist',
},
2019-08-31 04:07:25 +05:00
};
module.exports = {
inputs: {
email: {
type: 'string',
isEmail: true,
required: true,
2019-08-31 04:07:25 +05:00
},
password: {
type: 'string',
required: true,
2019-08-31 04:07:25 +05:00
},
name: {
type: 'string',
required: true,
},
2019-08-31 04:07:25 +05:00
},
exits: {
conflict: {
responseType: 'conflict',
},
2019-08-31 04:07:25 +05:00
},
async fn(inputs, exits) {
2019-08-31 04:07:25 +05:00
const values = _.pick(inputs, ['email', 'password', 'name']);
const user = await sails.helpers
.createUser(values, this.req)
.intercept('conflict', () => Errors.USER_EXIST);
return exits.success({
item: user,
2019-08-31 04:07:25 +05:00
});
},
2019-08-31 04:07:25 +05:00
};