passport.js

Does passportjs LocalStrategy allow more parameters than the default username and password?

你说的曾经没有我的故事 提交于 2019-12-22 04:55:13
问题 I'm new to javascript, node,and passportjs. Sorry if this is incorrect. I'd like to use 3 parameters in my passport local strategy: username, email, password . Is it possible? If so how? According to passportjs: "By default, LocalStrategy expects to find credentials in parameters named username and password. If your site prefers to name these fields differently, options are available to change the defaults." But can i add more paramaters? I tried this: passport.use('local-signup', new

Passport.js is not passing user to request in req.login()

╄→尐↘猪︶ㄣ 提交于 2019-12-22 03:58:45
问题 My passport.js configuration goes like so: const Local = require("passport-local").Strategy; const USMODEL = require("../models/user.js"); passport.serializeUser(function(user, done) { console.log("SERIALIZING USER"); done(null, user.id); }); passport.deserializeUser(function(id, done) { console.log("DESUSER", id); var US = mongoose.model("RegUser", USMODEL); US.findById(id, function(err, user) { done(err, id); }); }); passport.use("local-login", new Local({ usernameField: "email",

Passport.js + Express.js forward user to original destination after authenticating

妖精的绣舞 提交于 2019-12-22 03:45:16
问题 I have an app that is Node + Express + Passport on the server and jQuery + Backbone.js on the client. The client makes use of hash tags in the URL, but for some functionality it's important for the user to be logged in. I'd like the app to be accessible via URL, e.g. http://mydomain.com/app#cone/waffle/flavor/mint/toppings/sprinkles such that: if user is already logged in, they go to the requested URL directly without hassles if user is not already logged in, they go to /login and then go to

Passport and connect-flash: req.flash is not a function

假如想象 提交于 2019-12-22 01:38:13
问题 I'm learning flash messaging in passport and got stuck on this error when running my script: req.flash is not a function Here is my configuration: var flash=require("connect-flash"); app.use(flash()); passport.use(new LocalStrategy(function(req,username, password,done) { process.nextTick(function() { UserDetails.findOne({'username': username}, function(err, user) { if (err) { return done(err); } if (!user) { return done(null, false,req.flash('message','Invalid username or password')); } if

Simple Auth With Passport-Local and deSerializeUser problem

我的未来我决定 提交于 2019-12-21 22:21:08
问题 After reading an excellent description here on how deserialize and serialize user works in the Passport flow Understanding passport serialize deserialize I'm concerned about the performance impact of having deSerializeUser called on every request. All the examples I've seen (see below for one) have deserializeUser calling what looks like a database User.findById to do that work. Assuming you are not using a cdn for all your assets, that means many many database calls on every page load. My

Node+Passport.js + Sessions + multiple servers

不打扰是莪最后的温柔 提交于 2019-12-21 20:45:18
问题 Passport is great. I now discovered that I have some problem with how it handles sessions. I must be using it wrong. All works well for me with login + sessions + user data I store in my database. However I find that when I move to production environment (cloud on EC2 with multiple servers), I lose the login session each time. This is now clear to me - probably happens since the session is unique to each server. So my question is - how do I get around this.. I guess I will need to store my

Error: failed to find request token in session

三世轮回 提交于 2019-12-21 07:04:42
问题 I found a few issues on the main passport repo, however, I think this primarily pertains to this specific strategy as I'm able to successfully authenticate using the passport-google-oauth strategy. Error: failed to find request token in session at Strategy.OAuthStrategy.authenticate (/home/glug/application/node_modules/passport-dropbox/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:124:54) at attempt (/home/glug/application/node_modules/passport/lib/passport/middleware

How to combine passport and angular-ui routing

你说的曾经没有我的故事 提交于 2019-12-21 05:16:13
问题 I'm wondering how I can combine angular-ui-routing with passport. All examples I find are using the node.js routing there for. var routerApp = angular.module('routerApp', ['ui.router']); routerApp.config(function($stateProvider, $urlRouterProvider) { $urlRouterProvider.otherwise('/home'); $stateProvider .state('home', { url: '/home', templateUrl: 'partial-home.html' }) .state('about', { // for example just show if is loggedIn }); How would I implement this function in the above snippet?

How to get the profile of current user in node js

好久不见. 提交于 2019-12-21 05:13:10
问题 I am using MEAN Stack and mongoose. Using passport for authentication. I want to get the currently logged in user and display his details. For example if I am logged in and if I go to the profile page I want to get my details. There were only few resources on the internet. Login.js (passport and routes are here) var express = require('express'); var router = express.Router(); var passport = require('passport'); var LocalStrategy = require('passport-local').Strategy; var User = require('..

How to deal with async. findOrCreate method for passport and mongoose

冷暖自知 提交于 2019-12-21 05:05:14
问题 Authentication module 'Passport' requires a FindOrCreate method in order to do a login. I am using mongoose in order to save my users with the following schema: var UserSchema = new Schema({ firstname: String, lastname: String, email: String, accounts: [] }); The accounts array holds objects that represent facebook accounts, like {provider: "facebook", uid: "someFacebookId"} . My authentication strategy looks like this: // Authentication Strategy passport.use(new FacebookStrategy({ clientID: