passport.js

email field is optional in passportjs facebook strategy

佐手、 提交于 2019-12-08 00:04:11
问题 I wrote the code for login with facebook, everything works and I'm getting the user's email address. But there is another option on facebook which lets the user select the data my application is going to have access to. If user clicks on that, he'll see the name and everything marked as required, but email is optional and the user can remove it from the data that is going to be provided to the app. On the application, email is required. So how I can mark the email as required on facebook?

Accessing Passport's req.user within React (ES6)? API call returns req.user as undefined

一笑奈何 提交于 2019-12-07 21:31:27
问题 I'm making an app using React Starter Kit that uses Passport for authentication. I'm at the stage now where I'm trying to access the req.user object in the front end, but I'm having trouble passing that req.user object into the React/ES6 environment. I tried to pass the object as a prop and as context , to no avail. At this point, I decided to make an API endpoint where I can return the value of req.user as JSON, however req.user is being returned as undefined , despite it working fine under

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

two different login with node-passport

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 16:36:22
问题 I have the same application for 2 sites, the front-site and the backoffice.Both sites require a different condition to login because the backoffice needs to have the is_admin value in "true". this is my login method module.exports.verifyCredentials = function (username, password, done) { mongoose.model("User").findOne({password:password, username:username, is_admin:true}, function(err, user) { done(err, user); }); }; and this is in my app.js passport.use(new passportLocal.Strategy(securityCtl

How do I find original request path before redirect Express 4

可紊 提交于 2019-12-07 16:25:24
问题 Let's say I am trying to access the path http://localhost:3000/users#/WyCrYc28r/foo/1414585518343 . But the path /users needs to be accessed only by the authenticated users as following: app.get('/users', isLoggedIn, function (req, res) { req.session.user = req.user; res.cookie('uid', req.session.passport.user) .render('users', { title: 'The Foo Machine', user: req.user }); }); And following is the isLoggedIn middleware: function isLoggedIn(req, res, next) { if (req.isAuthenticated()) return

AngularJS - Access node/express session information

ぃ、小莉子 提交于 2019-12-07 12:12:11
问题 I am working on a node application that uses Express and Passport for authentication and authorization, and all of that is working properly. I am stumped, however, on how I would get the current user (set as req.user by Passport) in my Angular controllers. I want to be able to do normal things like displaying the username in a header/navigation bar (among other things), and I am currently doing this using the Jade view engine, but I don't like mixing using the Jade view engine for some "data

Passport Laravel Rest API Auth With Normal Design

落爺英雄遲暮 提交于 2019-12-07 11:48:00
问题 I have Completely assigned the Passport REST API and i get token and tested on PostMan and it retrieve the data with this Auth this is normal js html with laravel blade view (NOT VUE.JS) <script> $.ajax({ method: 'POST', dataType: 'json', url: "**********/api/User/GetPost", headers: { 'Authorization':'Bearer Tokenblablabla', 'Content-Type':'application/json' }, data: null, success: function(data){ console.log('succes: '+data); } }); this is the controller function public function GetPosts

passport.js - Access fail message after 401 error

限于喜欢 提交于 2019-12-07 11:10:35
问题 Currently I can access messages set in done(null, user, {message: 'ok'}) inside post request via req.authInfo like this: app.post('/reg', passport.authenticate('local-reg', { session: false }), function (req, res) { console.log(req.authInfo.message); --> 'ok' }); Which is very useful. But how can i access message like this done(null, false, {message: 'username taken'}) in the same fashion, as it seems that passing done(null, false) in passport.authenticate makes it throw 401 unathorised,

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

PassportJS - Is it possible to change req.user for another user?

混江龙づ霸主 提交于 2019-12-07 09:03:10
问题 In my application, I have implemented the ability to change a users permissions, rank, etc. It works great, if I update my own permissions, I can see the changes instantly since I can update the req.user object via req.login() . Problem is, when I update another users permissions, it updates in the database just fine, but the user will have to relog to see their permissions change since req.user still thinks they don't have the permission. This is fine if they're not logged in of course but