passport.js

How to catch FacebookAuthorizationError in passport-facebook / Passport.js?

不羁的心 提交于 2020-03-04 23:28:19
问题 I have an express app that uses Facebook authentication via Passport.js and the passport-facebook strategy. I have followed the documentation on how to handle authentication. It all works fine... until Facebook tries to report an error via the callback Url. In this case, I get an uncaught FacebookAuthorizationError exception, and the failureRedirect is not called. End users see an "Internal Server Error" as a result of the un-caught exception and I am in non-compliance with Facebook

passport don't redirect to 'failureRedirect' upon failure with facebook

微笑、不失礼 提交于 2020-03-02 09:08:21
问题 Im using passport to authenticate a user through Facebook. The successRedirect works great [I'm redirecting into http://localhost:3000/success#_=_ ], but the failureRedirect doesn't, i'm getting this: FacebookAuthorizationError: Login Error: There is an error in logging you into this application. Please try again later. [I'm getting this in my browser-> http://localhost:3000/auth/facebook/callback?error_code=1349003&error_message=Login+Error%3A+There+is+an+error+in+logging+you+into+this

What does passport.js do and why we need it?

两盒软妹~` 提交于 2020-02-18 09:03:17
问题 I am not familiar with user authentication in Node.js, now I am trying to create a website with a login system. I have managed to make it work using the code snippets from the website, but I don't really understand why we need the passport.js as a middleware to do the authentication. Registration: Let's take passport-local as an example, when we are using the passport middleware, we basically is trying to create a new document in the database, then can we do it without passport, such as using

No 'Access-Control-Allow-Origin' is present, Origin 'null' not allowed access - Passport-SteamStrategy, Node

家住魔仙堡 提交于 2020-02-01 05:47:09
问题 I have a site that is using Passport Steam Strategy. My server (Node with Express) is currently running on localhost:3000 while my front end is running on localhost:8080. I keep running into a cross-origin issue, only when attempting to authorize through Steam. My requests are made through Axios and I am using CORS. I've spent hours Googling and trying various things but I can't seem to get it to work. This is the error that I get: XMLHttpRequest cannot load https://steamcommunity.com/openid

(https:// wrapper is disabled in the server configuration by allow_url_fopen =0 [closed]

随声附和 提交于 2020-01-26 04:48:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 days ago . Hello Guys am working on laravel project and now i want to install passport for api in laravel i but i am getting an error during installation of passport in laravel project i was find the solution of this problem and i apply in it but still i am getting same error i have lost my

Redirecting to previous page after authentication using node.js and passport

妖精的绣舞 提交于 2020-01-24 21:50:49
问题 my authentication is working well but Redirecting to previous page after authentication using node.js and passport is not working *//this is auth.route.js file* app.post('/login', passport.authenticate('login',{ successRedirect : '/', failureRedirect : '/login', failureFlash : true })); *// this is ensureAuthenticated function* function isLoggedIn(req, res, next) { if (req.isAuthenticated()) return next(); else res.redirect('/login'); } 回答1: I found the how to do it. *//this is auth.route.js

How to keep alive an NodeJS Passport session

馋奶兔 提交于 2020-01-22 18:56:27
问题 We're Node + Express + Passport for authentication, and persisting the session info to Redis. I have maxAge set on the session cookie, to time out in one hour. That all seems to be working fine but the problem is, the session cookie will expire in one hour regardless of the user's activity. Is there a way I can manually refresh/keep alive the session cookie? 回答1: You'll likely want to use the "rolling" option for your session. This "forces a cookie set on every response" and "resets the

difference between 'done' and 'next' in node.js callbacks

為{幸葍}努か 提交于 2020-01-20 14:23:10
问题 in the passport [configure authentication] documentation, it has a rather scary-looking function that uses the mysterious function "done.' passport.use(new LocalStrategy( function(username, password, done) { User.findOne({ username: username }, function (err, user) { if (err) { return done(err); } if (!user) { return done(null, false, { message: 'Incorrect username.' }); } if (!user.validPassword(password)) { return done(null, false, { message: 'Incorrect password.' }); } return done(null,

Express.js + Passport.js : How to restrict multiple login by the same user?

回眸只為那壹抹淺笑 提交于 2020-01-20 04:57:06
问题 Passport by default allows the same user to login from multiple browsers and have unique sessions created. How can I configure it to destroy the first session when the user tries to create a second session? Currently I'm using the 'Sessions' model to add the username to the record and upon subsequent login check by username if the sessions exists. But this increases traffic to the db. I'm thinking express must be doing it already or made to, keep the 'logged in users' information in memory so

How to redirect the user back to the same page after authentication?

不羁的心 提交于 2020-01-17 06:18:51
问题 I am new to this whole node thing, and password is quite intriguing and seems to quite work for many of the authentications, so it looked cool. Scenario: I wanted to say, /profile to proceed, only when user is logged in. Here is the route I made, var express = require('express'); var router = express.Router(); the rest is in the file called router/index.js var passport = require('passport'); var ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn; router.post('/login', passport