Search Posts

Category: passport.js

Passport.js Redirect from express.js to angular 2 not working

I’m trying to redirect to an angular page after login where the login functions are coded in express.js.‘/api/login’, function(req, res, next) { passport.authenticate(‘local’, function(err, user, info) { if (err) { return next(err); // will generate a 500 error } if (! user) { //return res.send({ success : false, message : ‘login failed’ }); res.redirect(‘/api/login’); } //return res.send({ success : true, message : ‘login succeeded’ }); res.redirect(‘/dashboard’); })(req, res, next); }); After form submit, the […]

How To Mange Role based access control using postgres,nodejs,angularjs,express (PEAN.JS)?

I am able to login successfully, but how to use session and catch user id,name,roles that are stored in postgres database and send it to angularjs to authenticate the user based on their roles and restrict page which is only for admin. versions-> nodejs – 6.11.2, angularjs – 1.2, postgres – 9.5, express – 4.15‘*/login-check’, function (request, response) { console.log(request.body) var uid = request.body.username; console.log(uid);‘SELECT passwrd,email,user_role FROM mtcpl_user_profile WHERE uid = $1’, [uid]) […]