passport.js

How to avoid nesting structure of callbacks with promises? [finished]

半城伤御伤魂 提交于 2021-02-05 08:59:05
问题 I am using promises to avoid the nesting structure created by callbacks. However in this code I still have some nesting. Is there something I am doing wrong or is this un-avoidable in this case? In this case I want to check and see if a profile exists and if it does not I want to create it. DB.getProfile(id_google).then((resGet) => { if(!resGet[0]){ console.log('PROFILE - NOT FOUND - MUST CREATE'); DB.createProfile(id_google, email, name, pic_url).then((resCreate)=>{ console.log('PROFILE

Managing single sign on using passportjs for my own web applications - sharing login

泪湿孤枕 提交于 2021-02-04 19:24:45
问题 If I have 5 different web applications, all hosted on their own domains on different servers, could I use passport.js to create a single sign-on where users are redirected to a place to login for all web properties? Would I have to create my own custom strategy for this or there is a generic one I can use for this type of scenerio? 回答1: No matter if you are concern just for login or how ensure the authentication and authorization for your webs, apis and maybe your mobile apps, you will need :

Passportjs - req.logout function does not exist

早过忘川 提交于 2021-01-29 21:55:35
问题 I have a route that looks like so: exports.logout = function(res, req){ req.logout() // I blow up res.redirect('/') } Error: Object #ServerResponse has no method 'logout' The Request object does not contain a logout function when this route is called. I assume that this is because I have my middleware in the wrong order. Is that correct? This is what my configuration looks like: app.use(express.methodOverride()); app.use(express.static(path.join(__dirname, 'public'))); app.use(express

Setting Up Facebook Authentication with MongoDB Atlas and Passport.js

佐手、 提交于 2021-01-29 19:09:27
问题 I've done a lot of research to find this answer to my problem, but I haven't discovered anything. Feel free to attach a link if I missed the answer. I did find this solution, but I'm not exactly sure how it might apply to this situation: E11000 duplicate key error index in mongodb mongoose I'm trying to connect my Express.js, MongoDB, Passport.js app to Mongo-Atlas. I have my Atlas cluster set up and accepting new Users from my localhost and using Google Oauth 2.0, however, when I try to

My express.js and passport.js middleware are all working and are being called, but the page does not redirect

风流意气都作罢 提交于 2021-01-29 14:26:19
问题 I am currently developing a node/express server, and I decided to use passport-local for user authentication along with a local MongoDB server. I am using a POST method from an html form to send the two items, an email and a password (I changed the usernameField item in my instance of LocalStrategy). Using console.log's, I've seen all of the correct and expected behavior from Mongo and Passport. However, the page never redirects with successRedirect or failureRedirect. It looks like the html

on postman get session returns as expected, on chrome not

早过忘川 提交于 2021-01-29 08:05:41
问题 im using passport js express, when i login and get req.user on postman it works as i expect. But when i try on web browsers(im doing get request with axios) its doesnt work. The problem is passport.deserialize doesnt work on axios get. i tried different http get request methods (fetch, jquery.get, axios) its not about that. Also when i do manuel request to my server it turns as expected. I have different project, code is nearly same and works on that. I cant understand what is the problem.

Problem Redirecting after google signin in express react app using passport-google-oauth20

强颜欢笑 提交于 2021-01-29 07:19:32
问题 I have express backend and create-react-app2 as frontend , I am using setupProxy also. Now I have configured the app for google sign in however I am not getting proper redirect to index page after signin. Here is google oauth setup in console.developer.google.com I am using passport google oauth20 for authentication: Here my passport file: const GoogleStrategy = require('passport-google-oauth20').Strategy; const keys = require('./../keys/secret'); const {User} = require('./../models/user');

this._verify is not a function on login

試著忘記壹切 提交于 2021-01-29 05:11:17
问题 I am trying to make a CRUD app for my portfolio. I want the user to be able to sign up and login and then to some stuff once inside (its a calories tracker). The user can Sign Up but when I try to login, I get: this.verify is not a function Here is the login code: // Authenticate Login app.post("/login", (req, res, next) => { passport.authenticate("local", { successRedirect: "/myprofile", failureRedirect: "/login", failureFlash: true })(req, res, next); }); The passport.js const LocalStrategy

Passport local strategy auth seems to only work on localhost with a shared MongoDB instance

冷暖自知 提交于 2021-01-28 14:06:37
问题 This is a weird one, but I'm not sure what else could be going on. I've successfully deployed the passport-local strategy for a Node.js Express app with user accounts stored in MongoDB. I'm using Mongo as a service via MongoLab. My accounts and login auth works as expected locally. But when I deploy my app to AWS (using the same Mongo service still), the same account credentials fail. I'm wondering... is Passport somehow using the URL, port, or other environment-specific information to

How to get user address and phone number from google auth

不问归期 提交于 2021-01-28 12:16:56
问题 Iam using passport.js for authentication using passport-google-oauth20, I was wondering how can get user information like address, phone number ? so far i just can get information like email, name, profile but not address and phone number. how can access user data address after login with google ? Is there any API to access this user address and phone number ? what should I do ? this is my code : Passport setup passport.use( new GoogleStrategy({ //options for the google strategy callbackURL: