passport-local

Passport.js redirects to |successRedirect: '/profile'| but req.isAuthenticated() returns false

a 夏天 提交于 2019-12-04 05:31:33
问题 The following code is a section of an app developed by Node.js + Express + Passport.js. A valid user gets redirected to /profile url (successRedirect), however the req.isAuthenticated returns false and also the req.user is undefined . I couldn't figure out what might be the cause: app.post('/login', passport.authenticate('local', { successRedirect: '/profile',// <-- a valid user gets redirected to `/profile` failureRedirect: '/', failureFlash: true }) ); app.get('/profile',function(req,res){

Using Passport for Authentication of API Endpoints

筅森魡賤 提交于 2019-12-03 17:36:29
Following a couple tutorials on adding authentication using jsonwebtoken, passport, and passport-local I've become stuck on integrating it into my project . I want it so that any requests to any of the API endpoints require authentication, and also any requests to the front end which touch the API require authentication. What is happening now is I can get a user to log in and register but once they are logged in they are still unable to visit a page which is requiring authentication. The user gets a 401 error. It's like the token isn't being passed correctly in the request. I tried adding an

Passport local returns error 400 bad request with Angular

亡梦爱人 提交于 2019-12-03 10:47:59
I am trying to integrate passport to my code's login form. Client side calling server side works as it should until i call passport.authenticate in the request, 400 Bad Request was returned. What am I missing here. HTML <div> <div class="row"> <div class="input-field col s12"> <input id="user-email" type="text" ng-model="user.email"> <label for="user-email">Your email address</label> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="user-password" type="password" ng-model="user.password"> <label for="user-password">Your password</label> </div> </div> <div id="login

passport js missing credentials

情到浓时终转凉″ 提交于 2019-12-03 10:13:17
Been working on this for a few hours now, pretty frustrating... router.post('/', passport.authenticate('local-signup', function(err, user, info) { console.log(err); }), function(req, res){ console.log(req); res.setHeader('Content-Type', 'application/json'); res.send(JSON.stringify({ a: 1 })); }); When I run this, i used console.log , output was { message: 'Missing credentials' } , which leads me to believe that the body parser is not properly parsing the body message. When I use this route however... router.post('/', function(req, res){ console.log(req.body); res.setHeader('Content-Type',

Passport.js - Error: failed to serialize user into session

≯℡__Kan透↙ 提交于 2019-12-02 14:05:23
I got a problem with the Passport.js module and Express.js. This is my code and I just want to use a hardcoded login for the first try. I always get the message: I searched a lot and found some posts in stackoverflow but I didnt get the failure. Error: failed to serialize user into session at pass (c:\Development\private\aortmann\bootstrap_blog\node_modules\passport\lib\passport\index.js:275:19) My code looks like this. 'use strict'; var express = require('express'); var path = require('path'); var fs = require('fs'); var passport = require('passport'); var LocalStrategy = require('passport

Passport.js redirects to |successRedirect: '/profile'| but req.isAuthenticated() returns false

我们两清 提交于 2019-12-02 05:16:36
The following code is a section of an app developed by Node.js + Express + Passport.js. A valid user gets redirected to /profile url (successRedirect), however the req.isAuthenticated returns false and also the req.user is undefined . I couldn't figure out what might be the cause: app.post('/login', passport.authenticate('local', { successRedirect: '/profile',// <-- a valid user gets redirected to `/profile` failureRedirect: '/', failureFlash: true }) ); app.get('/profile',function(req,res){ console.log('req.user: \n'+req.user) console.log('req.isAuthenticated(): '+req.isAuthenticated()) // <-

req.session.passport and req.user empty, serializeUser and deserializeUser are never called

痞子三分冷 提交于 2019-11-30 15:06:53
I'm using Express (v4.11.2) with Passport in order to support multiple providers (local, facebook, twitter and google) for access to the web app I'm building. As a backend I'm using mysql. For now I have two local strategies: local-signup and local-signin. The issue I'm experiencing is that the req.session.passport and req.user are always empty and that, in fact, serializeUser and deserializeUser are never being called. Here is the setup of express and passport: var bodyParser = require('body-parser'); var session = require('express-session'); var MemoryStore = session.MemoryStore; var _ =

Passport: Allow sign up with name and email address? (Local Strategy)

房东的猫 提交于 2019-11-30 14:42:11
问题 Is there any way to allow a user to register on the local strategy with his password, email and name? Every example I could find online only use name/password or email/password. I also searched through the the whole passport documentation, but that documentation isn't helpful at all. It's just one bloated site full of examples. I just need an list of functions, classes and variables passport uses with explanations what they and every parameter of them do. Every good library has something like

Passport: Allow sign up with name and email address? (Local Strategy)

半城伤御伤魂 提交于 2019-11-30 11:38:03
Is there any way to allow a user to register on the local strategy with his password, email and name? Every example I could find online only use name/password or email/password. I also searched through the the whole passport documentation, but that documentation isn't helpful at all. It's just one bloated site full of examples. I just need an list of functions, classes and variables passport uses with explanations what they and every parameter of them do. Every good library has something like that, why can't I find it for passport? Here are the key parts of my code: passport.use('local-signup'

Support for multiple user types by Passport-local mongoose node.js

痴心易碎 提交于 2019-11-30 00:34:11
问题 I wanted two types of users logging in (User, Client). How exactly can I create localStrategies, serialize and deserialize user for both types in my app.js I have two separate schemas, both using the PassportLocalMongoose plugin. I currently configuraing my passport like below, var User = require('./models/User'); var Client= require('./models/Client'); passport.use(new LocalStrategy(User.authenticate(), Client.authenticate())); passport.serializeUser(User.serializeUser(), Client