aboutsummaryrefslogtreecommitdiff
path: root/controllers/user.js
diff options
context:
space:
mode:
Diffstat (limited to 'controllers/user.js')
-rw-r--r--controllers/user.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/controllers/user.js b/controllers/user.js
index c64bfa0..21ab829 100644
--- a/controllers/user.js
+++ b/controllers/user.js
@@ -11,9 +11,15 @@ module.exports = {
email: req.body.email,
password: bcrypt.hashSync(req.body.password)
});
- newUser.save().then(() => {
- req.login(newUser, () => res.redirect('/new-post'));
- });
+ newUser.save()
+ .then(() => {
+ req.login(newUser, () => res.redirect('/new-post'));
+ })
+ .catch(err => {
+ console.log(err);
+ req.flash('msg', 'Validation errors...');
+ req.redirect('/register');
+ });
}
else {
req.flash('msg', 'Validation errors...');