Skip to content
New issue

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

控制器里怎么取到登录用户的 ID? #122

Open
baiyuxiong opened this issue Dec 18, 2020 · 1 comment
Open

控制器里怎么取到登录用户的 ID? #122

baiyuxiong opened this issue Dec 18, 2020 · 1 comment

Comments

@baiyuxiong
Copy link

中间件的代码里只是验证的 token 是否有效,但是没取到用户是谁,这个在控制器里怎么取到?

@baiyuxiong
Copy link
Author

中间件里:

return func(c *gin.Context) {
c.Set("uid", res.Id)
}

放在gin.Context里,用的时候:

c.GetInt("uid")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant