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
我发现不能直接通过下面的方法来得到currentUser bookApi.get('/user', async ctx => { const user = ctx.currentUser; if (!user) { throw new NotFound({ msg: '没有user' }); } ctx.json(user); }); 这样是得不到ctx携带的currentUser信息的,请问有什么方法能直接在路由里获得ctx携带的currentUser
bookApi.get('/user', async ctx => { const user = ctx.currentUser; if (!user) { throw new NotFound({ msg: '没有user' }); } ctx.json(user); });
The text was updated successfully, but these errors were encountered:
ctx.currentUser 指的是当前登录的用户,使用了 groupRequired, loginRequired, adminRequired 其一才会把当前登录用户挂载到 ctx.currentUser上,具体的代码你可以看 app/middleware/jwt.js
ctx.currentUser
groupRequired
loginRequired
adminRequired
Sorry, something went wrong.
No branches or pull requests
我发现不能直接通过下面的方法来得到currentUser
bookApi.get('/user', async ctx => { const user = ctx.currentUser; if (!user) { throw new NotFound({ msg: '没有user' }); } ctx.json(user); });
这样是得不到ctx携带的currentUser信息的,请问有什么方法能直接在路由里获得ctx携带的currentUser
The text was updated successfully, but these errors were encountered: