From 5f58ad7e7b7546077556abd70fca44b296bb0c0c Mon Sep 17 00:00:00 2001 From: Mateja Date: Fri, 7 May 2021 00:27:51 +0200 Subject: Auto login on user registration. --- controllers/user.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/controllers/user.js b/controllers/user.js index 3f7b4a1..31afdfc 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -12,8 +12,7 @@ module.exports = { password: bcrypt.hashSync(req.body.password) }); newUser.save().then(() => { - req.flash('msg', 'You successfully registered.'); - res.redirect('/login'); + req.login(newUser, () => res.redirect('/new-post')); }); } else { -- cgit v1.2.3