passport.js

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

Setup page on first login, express.js

我只是一个虾纸丫 提交于 2019-12-24 07:10:04
问题 I'm using Passport.js to authorize user into my express.js app. I want to show setup page when user logins first time. Can I do this with Passport? 回答1: This Code MUST be modified mor your db, etc. Init The User: var user = new User({ ... }); user.newUser = true; And app.get("/account",requireLogin, function(req,res){ if(req.user.newUser){ req.user.newUser = false; req.user.save(function(err){ if(err) return handleError(err); res.redirect("/setup"); }) } }) 来源: https://stackoverflow.com

Handling authentication in Nodejs with passport-facebook-token, request coming from frontend Facebook SDK

余生长醉 提交于 2019-12-24 05:55:17
问题 I am working on a Unity App. For login, there are two methods, one using Email and another using Facebook. In case of login separately, I do not have any problem. Registration and Login with Email works perfectly. And Login with Facebook works perfectly as well. Here's the workflow, I created just to make you clear. tl;dr [read update] There's another schema for account , which is used for login. var Account = new Schema({ email: String, password: String, facebookId: String }); Things to know

Express.js Passport authentication automatically fails skips strategy

泄露秘密 提交于 2019-12-24 03:24:46
问题 UPDATE I have moved the code from the inside of the passport local-signup to a separate handler and it operates fine. The issue lies with Passport and the usage of the local-signup however I do not know why. I have a setup with Node.js (Express) + Passport for authentication and registration. This is a standard procedure have used it before however it does not seem to work. The passport registration goes immediately to the failureRedirect. The main issue is that the code doesnt hit any of the

Sails.js API passport.js authentication

流过昼夜 提交于 2019-12-24 03:23:39
问题 I am trying to develop an API backend in Sails.js. The most basic thing which I require is authentication. With that, I found the sails-generate-auth generator, I have followed all the steps listed at sails-generate-auth . Now, when I access http://localhost:1337/register , I see a simple registration form, same goes for login, and after logging in, I see a cookie set in my browser as sails.sid . After inspecting the AuthController.js I see that it has been written for server rendered views.

Why isn't res.redirect actually redirecting me?

别等时光非礼了梦想. 提交于 2019-12-24 01:53:21
问题 I have a basic login controller with a form that updates the $scope of the user. When they click a button the login() function is triggered. .controller('loginCtrl', ['$scope','$http',function($scope,$http) { $scope.user = { 'username' : "", 'password' : "" }; $scope.login = function(){ $http.post('/login', $scope.user).then(function (response){ console.log(response.data); }); } }]); And here is my routing for /login app.post('/login', function(req,res,next){ passport.authenticate('local

Passport.socketio has issues finding session

烈酒焚心 提交于 2019-12-24 01:45:28
问题 I am trying to access the session from sockets, but can't seem to make a connection. Without fail, authorization fails and I get the fail callback with the following message: failed connection to socket.io: No session found I will place all my code here so that it might be easier to spot what I'm doing wrong. var express = require('express'); var app = express(); var http = require('http'); var socketio = require('socket.io') var passportSocketIo = require('passport.socketio'); var port =

Node.js Passport get Facebook session on Page Load

不问归期 提交于 2019-12-24 01:29:49
问题 I've got the passport Facebook Strategy working fine. However, reading facebook documentation I stumble upon this : FACEBOOK DOCS A special consideration when using the Query String setting: If you would like to use the server-side authentication flow with App Center it is important to make sure you are passing the redirect_uri parameter correctly when exchanging your code for an access token. You should set your redirect_uri parameter to the click-through URL to your site. In most cases the

Just can't get Passport.js to work

北城余情 提交于 2019-12-24 00:47:12
问题 edit: sorry it's so long now, added in the compiled JS! I also added Kevs suggestions. I am developing a MEAN stack application (MongoDB, ExpressJS, Angular, NodeJS) and having a good time with it, especially with coffee script. My issue is that I can't get passport.js to work, every time it returns {success: false}. When I do a console.log in my LocalStrategy function it seems it's never even being called. Any idea why? Some snippets server.coffee (main file) ... Account = mongoose.model

Error: invalid_request Missing required parameter: scope (Restify & Passportjs w/ Google OAuth2)

廉价感情. 提交于 2019-12-24 00:46:08
问题 So, I've run into a problem with my Node.js app, using Restify and Passportjs (Google OAuth2 strategy). When I use passport.authenticate() , it gives me the following error: 400. That’s an error. Error: invalid_request Missing required parameter: scope I found another question about the same thing from a couple of years ago (invalid_request with missing: scope using Google Passportjs on Google Oauth2). The author said he finally fixed it himself but didn't post the fix. Has anyone else run