egg-jwt icon indicating copy to clipboard operation
egg-jwt copied to clipboard

ctx.state.user 可以提取到JWT编码的data,这里的原理是什么?

Open zhangxp426 opened this issue 4 years ago • 1 comments

ctx.state.user 可以提取到JWT编码的data,这里的原理是什么?

zhangxp426 avatar May 28 '20 02:05 zhangxp426

不负责任猜想:jwt作为路由的中间件,先于实际请求的controller执行,解码之后,就直接给app.state.user赋值了,然后你就拿到了,这和你自己写一个路由中间件,在这个中间件里面给ctx里面挂东西是一样的

qq295823929 avatar Jul 28 '21 08:07 qq295823929