passport-local

NestJS Authentification with JWT Passport not working

余生长醉 提交于 2020-05-16 03:14:10
问题 I am trying to set up a very simple login system using jwt-passport with nestjs. I followed this tutorial: https://docs.nestjs.com/techniques/authentication but I just can't get it to work. I am really new to this stuff and would appreciate if anyone can show me the way. The way I send the login to the server: this.clientAuthService.login(this.userName, this.password).then(response => { this.clientAuthService.setToken(response.access_token); this.router.navigate(['/backend']); }); My

Unable to set cookie in express + passport with nodejs

谁说我不能喝 提交于 2020-02-23 04:43:04
问题 Here i'm trying to set cookie when user select remember checkbox when user logins, but even the console.log("hello"); is not working. // process the login form app.post('/login',passport.authenticate('local-login', { successRedirect : '/profile', // redirect to the secure profile section failureRedirect : '/login', // redirect back to the signup page if there is an error failureFlash : true // allow flash messages }), function(req, res) { console.log("hello"); if (req.body.remember) { req

How to redirect the user back to the same page after authentication?

不羁的心 提交于 2020-01-17 06:18:51
问题 I am new to this whole node thing, and password is quite intriguing and seems to quite work for many of the authentications, so it looked cool. Scenario: I wanted to say, /profile to proceed, only when user is logged in. Here is the route I made, var express = require('express'); var router = express.Router(); the rest is in the file called router/index.js var passport = require('passport'); var ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn; router.post('/login', passport

knowing better authentication with Passport / JwtStrategy

送分小仙女□ 提交于 2020-01-06 07:18:16
问题 On one working project I downloaded from internet... In one location of the code I have the following: passport.use(new JwtStrategy({ secretOrKey: credentials.secret, jwtFromRequest: ExtractJwt.fromAuthHeader(), }, function(payload, done) { User.findById( payload._id, function(err, user) { if (err) { return done(err, false); } if (user) { return done(null, user); } else { return done(null, false); } } ); } )); In other location of the code I have the following: var requireAuth = passport

req.session.passport and req.user empty, serializeUser and deserializeUser are never called

家住魔仙堡 提交于 2019-12-30 04:58:25
问题 I'm using Express (v4.11.2) with Passport in order to support multiple providers (local, facebook, twitter and google) for access to the web app I'm building. As a backend I'm using mysql. For now I have two local strategies: local-signup and local-signin. The issue I'm experiencing is that the req.session.passport and req.user are always empty and that, in fact, serializeUser and deserializeUser are never being called. Here is the setup of express and passport: var bodyParser = require('body

Update or add fields in passport.js local-strategy?

旧城冷巷雨未停 提交于 2019-12-24 17:24:32
问题 Im all over the docs, but I cant seem to find a way to update credentials. This is what I was able to pick up by analyzing the code. passport.deserializeUser(function(id, done) { AppUser.findById(id, function(err, user) { done(err, user); }); }); DeserializeUser seems useful, but I am not sure how to use it to update a or add fields? I was trying to hack away and copy the logic from the login and make sense of it. passport.use('local-update', new LocalStrategy({ usernameField : 'username',

Passport.js - Local strategy doesn't authenticate

痞子三分冷 提交于 2019-12-24 09:08:43
问题 I've build a simple app that allows users to log in through google using passport's google strategy and it all works fine. I'm trying to add a local strategy as well, but I can't find a solution. Database works fine as users get created during sign up process. But redirecting to /profile doesn't work right after signing up. Instead, I get redirected to the login page; this normally happens when the user is trying to visit the /profile page but is not logged in. Logging in seems to work

passport-local-mongoose: createStrategy is not a function / authenticate is not a function

倖福魔咒の 提交于 2019-12-24 07:14:43
问题 I'm building on top of this starter project and trying to add user login with passport-local-mongoose. Depending on which of the two ways I try to use the strategy I'm getting either this error: [1] passport.use(User.createStrategy()); [1] ^ [1] TypeError: User.createStrategy is not a function or this error: [1] passport.use(new LocalStrategy(User.authenticate())); [1] ^ [1] TypeError: User.authenticate is not a function I've tried googling around a lot for a solution but can't seem to find

getting bad request while using passport in login form

时光怂恿深爱的人放手 提交于 2019-12-24 02:56:16
问题 I am trying to create a user login [.ejs file] form using passport local session in nodejs. My problem is that I keep on getting bad request when I hit on the submit button,can anyone please check my code and help me out Here is my nodejs code: required: var express = require('express'); var bodyParser = require('body-parser'); var passport = require('passport'); var LocalStrategy = require('passport-local').Strategy; var cookieParser = require('cookie-parser') var expressSession = require(

Express router create a new session not wanted

删除回忆录丶 提交于 2019-12-24 00:45:25
问题 I am doing a react project using express and passport-local for the authentication part based on this tutorial : https://scotch.io/tutorials/easy-node-authentication-setup-and-local The authentification work very well, I added the express router to define my routes for my api, but when I call for example "/api/myroute" the router of express creates an other session and I lose the user, so my function isLoggedIn blocks the call of my controllers because there is no user in this new session. So