Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- * signup() {
- const name = this.request.body.name;
- const email = this.request.body.email;
- const password = this.request.body.password;
- // validacions
- try {
- const user = yield users.add({
- name, email, password,
- });
- delete user.email;
- delete user.password;
- this.body = user;
- this.status = 200;
- } catch (error) {
- this.errors.push(error);
- this.status = 401;
- }
- },
- ///////
- * add(params) {
- const user = params;
- if (params.password) {
- const salt = yield bcrypt.genSalt(10);
- user.password = yield bcrypt.hash(params.password, salt);
- }
- return yield knex('users').insert(user)
- .then(users => users.toJSON());
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement