node-login icon indicating copy to clipboard operation
node-login copied to clipboard

Login Minor Bug

Open karthik2342323 opened this issue 4 years ago • 0 comments

Login without remember-me option as It will redirect to /home but even if session is assign then also while re-traversing index page It wont redirect to /home so to Fix this Inside routes.js replace this function with this function which is below

app.get('/', function(req, res){

 // This one is for If session is assign so redirect it 
	if(req.session.user)
	{
		res.redirect('/home');
	}
// check if the user has an auto login key saved in a cookie //
	else if (req.cookies.login == undefined){
		res.render('login', { title: 'Hello - Please Login To Your Account { For Exp} ' });
	}
	else{
// attempt automatic login //
		AM.validateLoginKey(req.cookies.login, req.ip, function(e, o){
			if (o){
				AM.autoLogin(o.user, o.pass, function(o){
					req.session.user = o;
					res.redirect('/home');
				});
			}	else{
				res.render('login', { title: 'Hello - Please Login To Your Account' });
			}
		});
	}
});

karthik2342323 avatar Apr 07 '21 22:04 karthik2342323