passport.js

NodeJS logout all user sessions

守給你的承諾、 提交于 2020-01-02 08:55:52
问题 I'm interesting to close (logout/sign out) all the user sessions in nodeJS . req.logout() is closing only the current session of the user. But for my security panel I want to add the option to close ALL the user sessions. How can I do this? I'm using MEAN.JS framework . With passport.js library and mongoDB to save the sessions: // Express MongoDB session storage app.use(session({ saveUninitialized: true, resave: true, secret: config.sessionSecret, cookie: { maxAge: 15778476000, httpOnly: true

NodeJS logout all user sessions

倾然丶 夕夏残阳落幕 提交于 2020-01-02 08:54:25
问题 I'm interesting to close (logout/sign out) all the user sessions in nodeJS . req.logout() is closing only the current session of the user. But for my security panel I want to add the option to close ALL the user sessions. How can I do this? I'm using MEAN.JS framework . With passport.js library and mongoDB to save the sessions: // Express MongoDB session storage app.use(session({ saveUninitialized: true, resave: true, secret: config.sessionSecret, cookie: { maxAge: 15778476000, httpOnly: true

How to create basic authentication, login system for a web tool made in node.js and socket.io, without using express

会有一股神秘感。 提交于 2020-01-02 06:54:12
问题 I have a web tool developed, which uses node.js and socket.io. it's a one page website and uses node.js for getting data from social media website and display on the same page. I would like to add a site specific login system for the website but don't want to use 'Express' or 'Passport' as it adds lots of overload to the website while it is not needed. I am newbie with node.js and would like to know if I need to have a login system made with node.js to maintain session of the logged in user?

Unable to access req.user with Passport.js and Express 4

南楼画角 提交于 2020-01-02 03:12:06
问题 I've been creating an app with Passport, Express 4 and Jade. I would like to show the user a navbar that changes when they log in. However, I cannot access req.user for any other page than the profile page, which calls isLoggedIn: function isLoggedIn(req, res, next) { // if user is authenticated in the session, carry on if (req.isAuthenticated()) return next() // if they aren't redirect them to the home page res.redirect("/login") } Using any other function to not redirect the user when not

passport authentication failed in basic example

≡放荡痞女 提交于 2020-01-01 09:56:34
问题 I am trying to break down this passport.js example to its most basic elements. I keep getting a 401 (Unauthorized) message and can't figure out why. Any help would be greatly appreciated. Thank you! Node.js file: var http = require('http'), express = require('express'), passport = require('passport'), LocalStrategy = require('passport-local').Strategy, flash = require('connect-flash'); var port = process.env.PORT || 8080; passport.serializeUser(function(user, done) { done(null, user); });

Using PassportJS with Connect for NodeJS to authenticate Facebook Users

南楼画角 提交于 2020-01-01 05:24:05
问题 I'm trying to integrate passport into my nodejs server using connect, but can't seem to do it properly. All the guides/examples use expressJS, so I tried my best to reformat the code to work with my code, but I can't seem to get it to work. The related parts are written below. Does anybody have any advice on what might be the problem? passport.authenticate() never seems to be called (at least the console.log message within the facebook authentication callback never prints). I'm currently not

PassportJS Custom Authenticate Callback Not Called

北城余情 提交于 2020-01-01 05:19:11
问题 Update: The below error was fixed by a commit. I've marked the first answer as 'correct', though the commit was brought to my attention in one of its comments I was hoping to utilize the custom callback to handle both successes and failures for logins in Passport's authenticate local strategy, but it looks like it's only called on success. Here is a snippet of what I'm talking about: passport.use(new LocalStrategy( {usernameField: 'email', passwordField: 'password'}, function(email, password,

How to provide frontend with JSON web token after server authentication?

孤人 提交于 2020-01-01 02:24:29
问题 So far I have only dealt with server-rendered apps, where after a user logs in via username/password or using an OAuth provider (Facebook etc.), the server just sets a session cookie while redirecting to the relevant page. However now I'm attempting to build an app using a more 'modern' approach, with React on the frontend and a JSON API backend. Apparently the standard choice for this is to use a JSON web token for authentication, however I'm having trouble working out how I'm meant to

How to redirect to correct client route after social auth with Passport (react, react-router, express, passport)

狂风中的少年 提交于 2020-01-01 00:45:10
问题 I have a React/Redux/React Router front end, Node/Express back end. I’m using Passport (various strategies including Facebook, Google and Github) for authentication. What I want to happen: Unauthenticated user attempts to access protected client route (something like /posts/:postid , and is redirected to /login . (React Router is handling this part) User clicks the ‘Log in with Facebook’ button (or other Social auth service) After authentication, user is automatically redirected back to the

ERR_HTTP_HEADERS_SENT: Cannot set headers after they are sent to the client

南笙酒味 提交于 2019-12-31 21:32:11
问题 I'm facing this weird issue in NodeJS when using with Passport.js, Express and Mongoose. Basically, I get an error saying "Cannot set headers after they are sent to the client" even though I don't send more than one header. I've read other posts and tried them out as well, and none of them worked. app.get - is there any difference between res.send vs return res.send Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client Cannot set headers after they are sent to