passport.js

NodeJS | How to be logined after closing browser using passport and express?

自作多情 提交于 2020-01-17 06:00:52
问题 I use in my project express and passport for working with session and it works fine instead of one problem. When i close browser my session deserialized and this is fine, but i need to be logined after connecting again. Should i save information in cookies or use another package in npm? A little bit about my code: app.use(session({ secret:'secret', maxAge: new Date(Date.now() + 3600000), httpOnly: true, cookie: { path: '/', httpOnly: true, maxAge: null}, store: new MongoStore(

When to use passport.js?

落爺英雄遲暮 提交于 2020-01-17 04:44:35
问题 I've been developing in node for the last months to try and understand the framework, and now I'm actually going to try to make an app for multiple devices. I want to use a node project as the api, which will handle all post and get requests. In another node project I would have a react web interface communicating with the node api with ajax and socket.io. In a mobile android/ios or cordova I would have the mobile interface communicating as above. Now that I've explained the background of my

Redirect to Frontend ( On A Different URL ) after OAuth2 Login

和自甴很熟 提交于 2020-01-16 22:54:27
问题 I am trying to setup my application as follow : Angular 7 frontend, served at, say http://localhost:4200 Express backend, served at, say http://localhost:3500 Passport library for OAuth2 Authentication I am setting up OAuth2 flow from the serverside (Express / Node.js). On clicking the Login button from the frontend, request is sent to the server, which gets redirected to Google to ask for user credentials / permissions etc. My callback URL is : http://localhost:3500/auth/callback. Post

req.session.destroy and passport logout aren't destroying cookie on client side

夙愿已清 提交于 2020-01-16 16:57:11
问题 I'm trying to destroy the cookie on the client side but can't seem to figure out how to. I've tried the few ways that passport and some answers on SO provided but I'm at a loss as to how to clear the actual cookie. My code so far is: app.get('/logout', function (req, res){ sessionStore.destroy(req.sessionID, (err) =>{ if(err)console.log(err); req.logout(); req.session.destroy(function (err) { if(err) console.log(err); res.status(200).json({message : 'User Logged Out'}); }); }); }); I have

Update existing user data in database

风流意气都作罢 提交于 2020-01-16 00:45:14
问题 Currently, I have managed to the save user information inside my database. However I wanted to update the user information inside my database when they logged in if there is changes of information inside Steam database. So it is the same inside my database. Below are example of information inside my User schema const UserSchema = mongoose.Schema({ username:{ type: String, }, profileURL:{ type: String, }, profileImageURL:{ type: String, }, steamId:{ type: String, } }); Below are example of my

How to make API call using API token in Node.js using express, passport-local

时光怂恿深爱的人放手 提交于 2020-01-14 05:59:50
问题 I'm a newbie in Node.js and trying to use API token to access Grafana. And I created one API token by following instruction from Grafana page. However, I don't know how to make API calls from my code of node.js to access my local server of grafana page. Also, I have a local login-page by using mongoDB to manage users. How can I make Node.js API calls to access my local server of grafana page? Please help me out here.. I'm having hard time on this.. If you want me to show code, I can edit here

Can I use the passport-google callback to authenticate android/ios users?

感情迁移 提交于 2020-01-13 16:30:34
问题 I have a node.js server which authenticates using google-passport-oauth2. My server-side code looks like that from the documentation: app.get('/auth/google', passport.authenticate('google', { scope: [ 'https://www.googleapis.com/auth/plus.login', , 'https://www.googleapis.com/auth/plus.profile.emails.read' ] } )); app.get( '/auth/google/callback', passport.authenticate( 'google', { successRedirect: '/auth/google/success', failureRedirect: '/auth/google/failure' })); I figure that /auth/google

FacebookTokenError: This authorization code has been used

北城以北 提交于 2020-01-13 06:52:10
问题 Ok, so this is a common error with many causes. I am trying to modify an existing Node-Passport-Facebook module to have local images from the desktop uploaded to a users Facebook account after they log in. That is my goal. This is the code module I am extending https://github.com/passport/express-4.x-local-example which in turn is based on https://github.com/jaredhanson/passport-facebook I never get past console.log('ERROR HERE.. . with an error of "This authorization code has been used."

Basic auth with passport and express

冷暖自知 提交于 2020-01-13 06:50:22
问题 I must have missed something, but according to all the tutorials I've found, this is how you do basic auth with a node application using express and passport + passport-local . I know it's not according to best practice, I'm just trying to get a POC going: 'use strict' var express = require('express'); var passport = require('passport'); var LocalStrategy = require('passport-local').Strategy var app = express(); var users = { 'user': 'secretpass'}; passport.use(new LocalStrategy( function

Restricting Login Access - Passport.js, Google Authentication

巧了我就是萌 提交于 2020-01-12 10:13:23
问题 Okay, so using passport.js works, and works well, from what I've seen. However, I'm not sure how to properly exclude certain users. If the application is intended to have restricted access, rather than just providing the user a method for logging in, how can I restrict the login through passport.js? As it stands, users can just visit /login and log in with their Google account, thereby getting access to the internals. 回答1: Here is one way to do this, with comments throughout. The main thing