We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
router.post('/login', app.passport.authenticate('local', { successRedirect: '/authCallback' }));
const jwt = app.passport.authenticate('jwt', { session: false, }); // controller.accounts.show 没有被执行,返回 404 Not Found router.get('/accounts/:id', jwt, controller.accounts.show);
我翻了下egg-passport的源码,在 lib/passport.js文件中,显示它调用的就是 passport.js 的authenticate方法
lib/passport.js
// lib/passport.js 39~49 authenticate(strategy, options = {}) { .... return super.authenticate(strategy, options); }
问题就在于 passport.js是 express 的中间件,它的authenticate 返回的形式是这样
// lib/middleware/authenticate.js 81~... return function authenticate(req, res, next) { ... }
koa 会将 ctx, next 作为参数传入, 这样即使鉴权成功,authenticate 也无法调用 next,就没法执行之后的逻辑了
The text was updated successfully, but these errors were encountered:
这样修改成功了: #1355 (comment)
Sorry, something went wrong.
No branches or pull requests
鉴权时,运行官网的代码没有问题
但是在鉴权后面加的逻辑时不会执行的
问题可能的原因
我翻了下egg-passport的源码,在
lib/passport.js
文件中,显示它调用的就是 passport.js 的authenticate方法问题就在于 passport.js是 express 的中间件,它的authenticate 返回的形式是这样
koa 会将 ctx, next 作为参数传入, 这样即使鉴权成功,authenticate 也无法调用 next,就没法执行之后的逻辑了
The text was updated successfully, but these errors were encountered: