passport.js

Payload error in jsonwebtoken

时间秒杀一切 提交于 2019-12-12 07:31:24
问题 I am making a web application using nodejs and angular cli I'm using JWT to authenticate my login function . But when I process it threw this error Error: Expected "payload" to be a plain object. at validate (D:\Mean_Projects\meanauthapp\node_modules\jsonwebtoken\sign.js:34:11) at validatePayload (D:\Mean_Projects\meanauthapp\node_modules\jsonwebtoken\sign.js:56:10) at Object.module.exports [as sign] (D:\Mean_Projects\meanauthapp\node_modules\jsonwebtoken\sign.js:108:7) at User

Continuous redirecting to Login page using passport node.js

自作多情 提交于 2019-12-12 04:53:45
问题 I am using node.js, express and passport and am having a continuous redirect to the login page. The strange thing is that the application is validating the user/passport, but then it renders the login page again. How can I get this to render the index page upon authentication? Is there something wrong with the session, such that it doesn't carry the authentication over from login to index? var mongoose = require('mongoose/'); mongoose.connect('mongodb://localhost/testdb'); passport = require(

bcrypt.compare() always returns false when verifying passwords

我只是一个虾纸丫 提交于 2019-12-12 04:49:58
问题 I followed this tutorial from scotch.io on how to build user authentication using node.js (great tutorial by the way). However, when verifyPassword(password) is called to check user password, the value is always returned as false for some reason. I'm using brcypt.js and sequelize.js for my express project. custom methods for model User: classMethods : { setPassword : function(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); } }, instanceMethods: { verifyPassword:

Passportjs not saving user into session after login

a 夏天 提交于 2019-12-12 04:25:33
问题 I'm working on a simple social network and I want users to register and log in locally trough passport.js. I was following thistutorial and all code runs with no errors. However when I try to log in User passes the authentication but doesn't stay in session when I print req.session on index route. Here is my passport config file: var LocalStrategy = require('passport-local').Strategy; var User = require('../server/models/User.js'); module.exports = function(passport){ passport.serializeUser

sending 2 flash messages when 2 queries to the databse show that fields exist in passport configuration

混江龙づ霸主 提交于 2019-12-12 04:13:16
问题 On signup I check the database to see if the username and email exists if they exist it should return an error. all usernames and emails should be unique. It seems that my problem is that I could only get one error. If the email exists already I get the flash message but if the username also exists it doesn't say anything about the username already existing. I want to display both errors If both exist already on post in a flash message I'm assuming the problem is returning done() for the

Cannot get properties of req.user

社会主义新天地 提交于 2019-12-12 03:43:59
问题 I'm using Passport to auth My projec. After successful auth, users are directed to "/home".At this point, the request has the user object. However, once I redirect, the req.user.email is undefined. :'( exports.test= function (req, res) { console.log(req.user); console.log(req.user.id); console.log(req.user.email); } the terminal display : ModelBase { attributes: { id: 18, first_name: 'test', last_name: 'test', email: 'test1@gmail.com', password: '18fa9883b74578494b578048273e66d2edbf57b6',

Express-session with passport.js multiple cookies

自古美人都是妖i 提交于 2019-12-12 03:27:36
问题 I'm trying to implement the login functionality with passport.js and express-session, it works well, var passport = require('passport'), session = require('express-session'), MongoDBStore = require('connect-mongodb-session')(session); var sessionStore = new MongoDBStore({ uri: config.db, collection: 'sessions' }); var sessionOptions = { name: 'very-secure-cookie', secret: config.secret, resave: false, saveUninitialized: true, cookie: { secure: true, maxAge: null }, store: sessionStore }; app

Query object within an object

烂漫一生 提交于 2019-12-12 03:26:12
问题 I'm using passport.js to store my users into my mongodb. A user object looks like this { "_id" : ObjectId("545ac4930acf4b5394cbc244"), "local" : { "password" : [encrypted password], "email" : "john@domain.com", "level" : "super user", }, "__v" : 0 } I'm attempting to display all the users who are part of the "super user" group. I'm finding this difficult as my data sits two levels within the object. 回答1: Use the dot notation like this: db.users.find({"local.level" : "super user"}) To return

invalid_request with missing: scope using Google Passportjs on Google Oauth2

跟風遠走 提交于 2019-12-12 03:20:01
问题 An issues has developed in authentication code that was working perfectly up until the beginning of the year, and then seemingly broke with little change on my part, I've tried to regress to a previous version and find the cause with no luck. So I'm Looking for help in fixing the code as it exists today. I'm using nodejs v0.10.25 Passportjs to provide authentication through both Google and Facebook. My packages: "config-multipaas": "^0.1.0", "restify": "^2.8.3", "googleapis": "~2.1.5", "mocha

express-session req.user is undefined

早过忘川 提交于 2019-12-12 03:08:35
问题 I'm trying to use express session to login users. I'd like users to be able to go to a profile page and view their user data if they have logged in. I've been stuck here for days. On line 33 of my routes.js file, in my /profile GET route, req.user is undefined. But on line 27 of my routes.js , in my /login POST , req.user works as it should. 'use strict' var User = require('mongoose').model('User') module.exports = function(app, passport){ console.log('passport', passport) app.route('/') .get