Search Posts

Category: passport.js

How do I display the Steam OpenID page in a popup window?

On the server side I have implemented a working authentification via passport-steam. When I open the URL …/api/v1/connect/steam it redirects me to the Steam Login page and when I succesfully log in, it redirects me back to returnURL. But now I want to connect it with my frontend and this is where I’m a bit lost. To access …/api/v1/connect/steam I have to send an authorization header (Firebase Authentification) with Bearer <token>. Otherwise I can’t access […]

How to wait for authentication check before loading default state in angularjs applicaton with ui-router

I have an angularjs application that is using $transitions to check if a user is authenticated before certain $state changes. I am using passport.js to do the authentication strategy. If authentication has not occurred or fails the AuthisLoggedIn() check I want the user to be reverted back to the ‘login’ state. The issue I am having is that the default state ‘/’ always seems to load before my authentication promise, Auth.getCurrentUserAsync() is done executing causing […]

Need help understanding how NodeJS / PassportJS works

I have the following 3 fragments of code taken from a working project I downloaded from internet: file: ./routes.js // … var passport = require(‘passport’); var requireLoginLocal = passport.authenticate(‘local’, { session: false }); var authController = require(‘./controllers/authController’); // … module.exports = function(app) { // …‘/login/local’, requireLoginLocal, authController.login); // … } file: ./config/passport.js // … var LocalStrategy = require(‘passport-local’).Strategy; // … module.exports = function(passport) { passport.use(new LocalStrategy({ usernameField: ’email’ /* changing default */ }, function(email, […]

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