Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User.findOne({where: {username: req.body.username}}).then(user => {
- if (!user) {
- User.create({username: req.body.username, password: bcrypt.hashSync(req.body.password)})
- .then(() => res.status(201).send({message: "Created user."}))
- .catch(err => next(err));
- } else {
- res.status(400).send({message: "Username already exists."});
- }
- });
Add Comment
Please, Sign In to add comment