Fix bug of get context user (#17169)
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
a82c799fc8
commit
37b29319aa
2 changed files with 12 additions and 10 deletions
|
@ -547,6 +547,17 @@ func GetContext(req *http.Request) *Context {
|
|||
return req.Context().Value(contextKey).(*Context)
|
||||
}
|
||||
|
||||
// GetContextUser returns context user
|
||||
func GetContextUser(req *http.Request) *models.User {
|
||||
if apiContext, ok := req.Context().Value(apiContextKey).(*APIContext); ok {
|
||||
return apiContext.User
|
||||
}
|
||||
if ctx, ok := req.Context().Value(contextKey).(*Context); ok {
|
||||
return ctx.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SignedUserName returns signed user's name via context
|
||||
func SignedUserName(req *http.Request) string {
|
||||
if middleware.IsInternalPath(req) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue