koa-passport

koa-passport Authentication Always Returns 4XX

我是研究僧i 提交于 2020-04-30 11:21:45
问题 When using koa-passport I am always receiving a 404 or 401 error. passport.authenticate( 'local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true } ); 回答1: (This gave me many hours of struggle so wanted to post it here for others.) When using koa-passport you must be sure to both return the result of the authentication, and call authenticate with the context . return passport.authenticate( 'local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true } )

koa-passport Authentication Always Returns 4XX

心不动则不痛 提交于 2020-04-30 11:21:07
问题 When using koa-passport I am always receiving a 404 or 401 error. passport.authenticate( 'local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true } ); 回答1: (This gave me many hours of struggle so wanted to post it here for others.) When using koa-passport you must be sure to both return the result of the authentication, and call authenticate with the context . return passport.authenticate( 'local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true } )

Automatically logging in a user with KoaJS and PassportJS

丶灬走出姿态 提交于 2019-12-25 03:34:52
问题 I'm trying to automatically log in a user with PassportJS. This is my current code: myRouter.get('/signin', function* (next) { user = {...}; var res = this.res; // needed for the function below this.req.login(user, function(err) { if (err) console.log('error logging in user - '+err); return res.redirect('/'); // <--- line 439 }); }); But when I run it, I get the error: error logging in user - TypeError: undefined is not a function TypeError: undefined is not a function at /srv/www/domain.com