passport-local

Having issues with integrating passport-local with restify

本秂侑毒 提交于 2019-12-07 19:01:43
问题 My sample application is as follows var util = require("util") restify = require("restify"), q = require("q"), _ = require("lodash"); //Create Server var server = restify.createServer({ name: "TestAuth" }); server.use(restify.queryParser()); server.use(restify.bodyParser()); //Initialize Passport var passport = require("passport"), LocalStrategy = require("passport-local").Strategy; server.use(passport.initialize()); passport.use(new LocalStrategy( function(username, password, done) { return

Does the passport.js support ajax?

巧了我就是萌 提交于 2019-12-07 10:18:30
问题 I want to make ajax login with the passport.js. I have the usual code for setting the passport.js: //route app.post('/api/auth/login', passport.authenticate('local-login', { successRedirect: '/', failureRedirect: '/login' })); //config strategy passport.use('local-login', new LocalStrategy({ usernameField: 'email', passwordField: 'password', passReqToCallback: true }, loginUser)); var loginUser = function(req, email, password, done) { UserRepo.getOne({ 'local.email': email }).done(function

Passport.js strategy with no field required

五迷三道 提交于 2019-12-07 07:36:19
问题 I'm surprised that it's so hard to find, or maybe something wrong with me. I need a passport.js strategy that requires no fields - to run authentication with it on simple user GET request to '/' and manipulate user session data to, for example, make a new 'guest' user. Maybe i can do this via passport local-strategy ? Or am i need to create a custom one? I saw this Configure Passport to accept request without body? question, yet i just simply can't figure out how the suggested in answer

Passport.js throwing “undefined is not a function” with LocalStrategy

余生长醉 提交于 2019-12-06 14:14:03
I am implementing local authentication using Passport.js. I have already implemented Github Oauth, which is fine but for some reason the local strategy is failing with the above error. I cannot find any source of the issue so far. I have read other posts but the usual answer is that you should change the require statement to: var LocalStrategy = require('passport-local').Strategy; However, I have already done this. Any help would be much appreciated. Here are my files as it stands. I have omitted the github strategy code to focus on the problem strategy: signin.html: <div class="signin-bg"> <!

Using Passport for Authentication of API Endpoints

时光毁灭记忆、已成空白 提交于 2019-12-05 03:17:47
问题 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

passport js missing credentials

梦想的初衷 提交于 2019-12-04 16:07:55
问题 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

Simple Auth With Passport-Local and deSerializeUser problem

家住魔仙堡 提交于 2019-12-04 15:22:01
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 questions is am I mis-understanding the use case somehow? Is it possible that it is being recommended to

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

*爱你&永不变心* 提交于 2019-12-04 07:27:17
问题 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'

how to get passport.authenticate local strategy working with async/await pattern

我的未来我决定 提交于 2019-12-04 07:09:13
I've been failing to get passport.authenticate to work at all inside of an async/await or promise pattern. Here is an example I feel should work, but it fails to execute passport.authenticate(). const passport = require("passport"); let user; try { user = await __promisifiedPassportAuthentication(); console.log("You'll never have this ", user); } catch (err) { throw err; } function __promisifiedPassportAuthentication() { return new Promise((resolve, reject) => { console.log("I run"); passport.authenticate('local', (err, user, info) => { console.log("I never run"); if (err) reject(err); if

how to send json as a response after passport authenticationin node.js

喜夏-厌秋 提交于 2019-12-04 06:45:08
I am trying this git example . Which works well when I integrated it with my project, but what I want to achieve is to send json as a response to the client/request, instead of successRedirect : '/profile' & failureRedirect : '/signup'. Is it possible to send a json, or is there some other methods to get the same? Any help will be appreciated,TU You can use passport's authenticate function as route middleware in your express application. app.post('/login', passport.authenticate('local'), function(req, res) { // If this function gets called, authentication was successful. // `req.user` contains