passport.js

Bad Request when registering with passport

非 Y 不嫁゛ 提交于 2021-01-28 10:47:27
问题 I am trying to build an authentication panel for the MEAN stack using PassportJS. I have the following code for registering new users with email (instead of the default username) and password: router.post("/register", function (req, res) { var newUser = new User({ username: req.body.email }); User.register(newUser, req.body.password, function (err, user) { if (err) { return res.render('account/signup'); } passport.authenticate("local")(req, res, function () { res.redirect("/account/profile");

PassportJS authenticates user but returns 401 Unauthorized on subsequent requests

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-27 19:39:40
问题 I'm writing one of my first applications in NodeJS so please bear with me. I've managed to successfully authenticate a user to our Active directory and I can see the connect.sid cookie being set and used on the subsequent requests. Upon debugging the application by dumping the req object I can also see that the user variable has been set successfully. From the documentation I've read that seems to be a criteria for a successful session match? However, the request is still getting a 401

user.setPassword is not a function - passport local mongoose

本秂侑毒 提交于 2021-01-27 19:06:21
问题 I am implementing a reset password feature on for the users of my website. However, it seems to throw this error when the user confirms new password at the reset.ejs page. The following steps are being performed correctly: Token sent on mail When clicked on token, new password page opens When user enters new password and confirm new password and hits the button to save the new password, the function in users.js user.setPassword does not work as the error is mentioned below. It is a built in

passport.authenticate() using a Promise instead of a Custom Callback

寵の児 提交于 2021-01-27 12:14:07
问题 passport.authenticate() , how can I define a Promise instead of using a Custom Ballback ? How to used passport.authenticate() is referenced within here: http://www.passportjs.org/docs/authenticate/ Within this page, there is a section Custom Ballback : If the built-in options are not sufficient for handling an authentication request, a custom callback can be provided to allow the application to handle success or failure. app.get('/login', function(req, res, next) { passport.authenticate(

Installing PassportJS with PostgreSQL

旧城冷巷雨未停 提交于 2021-01-20 16:42:25
问题 Is there a walkthrough tutorial for setting up PassportJS with PostgreSQL (i.e., replacing MongoDB with PostgreSQL)? 回答1: Well this is open for a while, but since I found myself with the same issue here it goes. The only thing you have to do is define the localStrategy with Postgres like so: passport.use(new LocalStrategy({ usernameField: 'email', passwordField: 'pass' }, (username, password, done) => { log.debug("Login process:", username); return db.one("SELECT user_id, user_name, user

What is the best practice to use Oauth2, React, Node.js and Passport.js to authenticate user with Google sign on button?

血红的双手。 提交于 2021-01-17 04:33:30
问题 I want to have a login button in my website so when a user clicks on it, the user can use their Google credentials. I'd like to ideally perform the authentication server side using Express.js and Passport.js. I implemented authentication server-side but the problem is that I can't make an AJAX request from the website to the server to start authentication because Google or Oauth don't support CORS. So I need to use a href element in my website which would call the server authentication

What is the best practice to use Oauth2, React, Node.js and Passport.js to authenticate user with Google sign on button?

孤者浪人 提交于 2021-01-17 04:33:26
问题 I want to have a login button in my website so when a user clicks on it, the user can use their Google credentials. I'd like to ideally perform the authentication server side using Express.js and Passport.js. I implemented authentication server-side but the problem is that I can't make an AJAX request from the website to the server to start authentication because Google or Oauth don't support CORS. So I need to use a href element in my website which would call the server authentication

What is the best practice to use Oauth2, React, Node.js and Passport.js to authenticate user with Google sign on button?

僤鯓⒐⒋嵵緔 提交于 2021-01-17 04:31:39
问题 I want to have a login button in my website so when a user clicks on it, the user can use their Google credentials. I'd like to ideally perform the authentication server side using Express.js and Passport.js. I implemented authentication server-side but the problem is that I can't make an AJAX request from the website to the server to start authentication because Google or Oauth don't support CORS. So I need to use a href element in my website which would call the server authentication

What is the best practice to use Oauth2, React, Node.js and Passport.js to authenticate user with Google sign on button?

亡梦爱人 提交于 2021-01-17 04:24:38
问题 I want to have a login button in my website so when a user clicks on it, the user can use their Google credentials. I'd like to ideally perform the authentication server side using Express.js and Passport.js. I implemented authentication server-side but the problem is that I can't make an AJAX request from the website to the server to start authentication because Google or Oauth don't support CORS. So I need to use a href element in my website which would call the server authentication

Graphql query to check passport/google authentication

孤人 提交于 2020-12-13 04:48:16
问题 I want to implement graphql query to check if I'm logged in or not. First part is similar for what we all can see on passport docs and youtube/github tutorials: I: Introduction(if anybody know what is all about you can skip to problem part): modules/auth.js const GoogleStrategy = require('passport-google-oauth20').Strategy const passport = require('passport'); const User = require('../models/user'); passport.serializeUser((user, done) => { done(null, user.id) }) passport.deserializeUser((id,