egg icon indicating copy to clipboard operation
egg copied to clipboard

egg-passport-local添加localStrategy中间件后如何进入controller

Open fuufuuf opened this issue 8 years ago • 8 comments

  • 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提交的表单,需要在登陆成功/失败后给提示,不是直接跳转。

fuufuuf avatar May 17 '18 03:05 fuufuuf

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.

egg-bot avatar May 17 '18 03:05 egg-bot

@fuufuuf 请问你最后怎么解决啊?

silentsiri avatar May 30 '18 09:05 silentsiri

@fuufuuf @farzer 请问问题解决了没有?egg-passport调用app.passport.authenticate('local')时如果没有带参数,默认redirect到“/”,没有找到api可以不redirect的。Passportjs好像有自定义回调函数,但passportjs上的demo放在egg上好像用不了。求解决方案。

jjackychen avatar Jun 04 '18 03:06 jjackychen

我也发现了一定要redirect...原来的passport是可以不用redirect

coolicer avatar Nov 05 '18 07:11 coolicer

@atian25 @fengmk2

Cheonsoon avatar Nov 16 '18 04:11 Cheonsoon

cc @thonatos

atian25 avatar Nov 16 '18 05:11 atian25

我是让他重定向到另外一个接口,通过这个接口返回json数据。现在就是没办法,在错误的时候讲错误提示返回。

qzhongyou avatar Apr 26 '19 07:04 qzhongyou

官方文档写的真的不行,做个完整的demo有这么难吗?搞得浪费时间在这些没有半点技术含量的地方

famingyuan avatar Aug 23 '20 05:08 famingyuan