Search Posts

Category: passport.js

How to call nodejs’s passportJS-OAuth2 API from Angular cli?

NodeJs configured and running fine with passportJS OAuth2, but the requirement is angular is my front-end, both are runs in different ports, calling all nodeJS’s rest API from angular and it runs fine using proxy.conf.json, while calling /googleauth/redirect from angular getting error response. Response : Failed to load… No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:4200’ is therefore not allowed access. Google API Setting : Restrictions Authorised JavaScript origins : http://localhost:4200 […]

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]) […]