Open gitp18 opened 5 years ago
You are right. If you want to make a pull request I will check it out and accept
I am using sequelize and it doesn't save the session, after I login and I go to login router again, it still on login form,
Another thing to improve the UX would be to log the user in automatically after registering
in "routes/users.js" add this code
req.login(user, function(err) { if (err) { return next(err); } return res.redirect('/dashboard'); });
bcrypt.hash(newUser.password, salt, (err, hash) => {
if (err) throw err;
newUser.password = hash;
newUser
.save()
.then(user => {
req.login(user, function(err) {
if (err) { return next(err); }
return res.redirect('/dashboard');
});
})
.catch(err => console.log(err));
});
}); ```
If somebody finds solution for this then please comment out here
After successful sign up, http://localhost:5000/users/login and http://localhost:5000/users/register should redirect to http://localhost:5000/dashboard page, until the user sign out.