egg-passport-local添加localStrategy中间件后如何进入controller
- Node Version:
- Egg Version:
- Plugin Name:
- Plugin Version:
- Platform:
- Mini Showcase Repository:
router.js ... const localStrategy = app.passport.authenticate('local'); app.router.post('/users/login', localStrategy, app.controller.users.login); ... 我想在localStrategy完成后进入app.controller.users.login进一步操作,程序并没有跳入。请问如何进入。实现的原因是我的登陆界面使用ajax提交的表单,需要在登陆成功/失败后给提示,不是直接跳转。
Translation of this issue:
egg-passport-local How to enter controller after adding localStrategy middleware
- Node Version:
- Egg Version:
- Plugin Name:
- Plugin Version:
- Platform:
- Mini Showcase Repository:
Router.js ... Const localStrategy = app.passport.authenticate('local'); App.router.post('/users/login', localStrategy, app.controller.users.login); ... I want to go into app.controller.users.login after the localStrategy is complete. The program does not jump in. How to enter. The reason for the implementation is that my login interface uses the form submitted by AJAX. You need to give a prompt after the login success/failure, not directly.
@fuufuuf 请问你最后怎么解决啊?
@fuufuuf @farzer 请问问题解决了没有?egg-passport调用app.passport.authenticate('local')时如果没有带参数,默认redirect到“/”,没有找到api可以不redirect的。Passportjs好像有自定义回调函数,但passportjs上的demo放在egg上好像用不了。求解决方案。
我也发现了一定要redirect...原来的passport是可以不用redirect
@atian25 @fengmk2
cc @thonatos
我是让他重定向到另外一个接口,通过这个接口返回json数据。现在就是没办法,在错误的时候讲错误提示返回。
官方文档写的真的不行,做个完整的demo有这么难吗?搞得浪费时间在这些没有半点技术含量的地方