passport-local

Node Passport invitation strategy

…衆ロ難τιáo~ 提交于 2019-12-11 13:14:11
问题 I’m creating a multi-user app where only the admin can add new users through an invitation. I looked at Passport but I don’t see a way to implement a kind of “invitation strategy” (similar to Devise in RoR); any ideas ? 回答1: The Strategy is how you authenticate someone, where Invitations are about how users register. They're two different areas of concern in your app. What I do is have the Invitation be created by the admin and so on, and when the user clicks on the link to their invitation

Lose cookie/session when reload page

Deadly 提交于 2019-12-11 08:34:19
问题 I have two separate applications: AngularJS client working on http://localhost:8080 NodeJS API server working on http://localhost:3000 NodeJS API Server just gives json data to client (and does not give any html pages). I store information about autentificated user in sessionStorage. The Problem: When I login into system and reload page, I lost information about user in sessionStorage. Here is my AngularJS auth service: module.exports = function($http, $location, $cookies, $alert, $window) {

Node.js / Express: POST being turned into GET (code 302)

▼魔方 西西 提交于 2019-12-10 15:15:44
问题 In brief, I have a login page where my POST request is turning into a GET in Express 4. Here is the business part of my login page: <form id='loginForm' action='/login' method='post'> <table> <tr> <td><input type='text' name='username' /></td> </tr> <tr> <td><input type='text' name='password' /></td> </tr> <tr> <td><button type='submit'>Submit</button></td> </tr> </table> </form> Here are routes I set: // Express 4 var router = express.Router(); router.get('/login', function(req, res) { res

Session is not correctly obtained from a storage, using express-session and passportjs

大兔子大兔子 提交于 2019-12-10 13:56:51
问题 I'm using passport , express-session and connect-pg-simple . The problem is that session is not correctly obtained from a storage , where it gets properly (i hope, but doubt) saved. My setup is the same, as in many tutorials, I've found around. server.js: import express from 'express'; import next from 'next'; import bodyParser from 'body-parser'; import session from 'express-session'; import connectPgSimple from 'connect-pg-simple'; const sessionStorage = connectPgSimple(session); import

Passport.js throwing “undefined is not a function” with LocalStrategy

て烟熏妆下的殇ゞ 提交于 2019-12-10 11:06:37
问题 I am implementing local authentication using Passport.js. I have already implemented Github Oauth, which is fine but for some reason the local strategy is failing with the above error. I cannot find any source of the issue so far. I have read other posts but the usual answer is that you should change the require statement to: var LocalStrategy = require('passport-local').Strategy; However, I have already done this. Any help would be much appreciated. Here are my files as it stands. I have

how to get passport.authenticate local strategy working with async/await pattern

安稳与你 提交于 2019-12-09 17:16:01
问题 I've been failing to get passport.authenticate to work at all inside of an async/await or promise pattern. Here is an example I feel should work, but it fails to execute passport.authenticate(). const passport = require("passport"); let user; try { user = await __promisifiedPassportAuthentication(); console.log("You'll never have this ", user); } catch (err) { throw err; } function __promisifiedPassportAuthentication() { return new Promise((resolve, reject) => { console.log("I run"); passport

how to send json as a response after passport authenticationin node.js

こ雲淡風輕ζ 提交于 2019-12-09 17:10:20
问题 I am trying this git example. Which works well when I integrated it with my project, but what I want to achieve is to send json as a response to the client/request, instead of successRedirect : '/profile' & failureRedirect : '/signup'. Is it possible to send a json, or is there some other methods to get the same? Any help will be appreciated,TU 回答1: You can use passport's authenticate function as route middleware in your express application. app.post('/login', passport.authenticate('local'),

Passport local returns error 400 bad request with Angular

对着背影说爱祢 提交于 2019-12-09 07:53:44
问题 I am trying to integrate passport to my code's login form. Client side calling server side works as it should until i call passport.authenticate in the request, 400 Bad Request was returned. What am I missing here. HTML <div> <div class="row"> <div class="input-field col s12"> <input id="user-email" type="text" ng-model="user.email"> <label for="user-email">Your email address</label> </div> </div> <div class="row"> <div class="input-field col s12"> <input id="user-password" type="password" ng

PassportJS(Local) with Sequelize and Express stuck on pending after serializing user

爷,独闯天下 提交于 2019-12-08 07:59:51
问题 I'm trying to make login work, using the tutorial I've found in http://code.tutsplus.com/tutorials/authenticating-nodejs-applications-with-passport--cms-21619. I modified the code to work with Sequelize. I was able to verify username and password, but after serializing a user, the page that it redirects to does not load. I was wondering if there's something I missed. I'm not really getting an error, but redirecting to /test/home page is stuck on pending, and it keeps executing a post request.

passport local type error

谁说胖子不能爱 提交于 2019-12-08 03:22:35
问题 I'm trying to use passport-local for authentication in my Sails project. In my controller: passport.authenticate('local', function(err, user, info) { if ((err) || (!user)) { res.json({message: 'Unable to authenticate'}); return; } req.login(user, function(err) { if (err) { res.json({message: 'Unable to login'}); console.log(err); return; } res.json({message: 'logging in'}); }); })(req, res); In a config file: passport.use(new LocalStrategy(function(username, password, done) { User