Improvements for tokens
This commit is contained in:
parent
effa79aacd
commit
8ccd490bed
15 changed files with 34 additions and 30 deletions
|
|
@ -41,11 +41,15 @@ func (auth *Auth) SessionOf(r *http.Request) (session component.SessionInfo, use
|
|||
if err != nil {
|
||||
return component.SessionInfo{}, nil, err
|
||||
}
|
||||
if user == nil {
|
||||
return component.SessionInfo{}, nil, nil
|
||||
}
|
||||
return component.SessionInfo{User: &user.User, Token: false}, user, nil
|
||||
}
|
||||
}
|
||||
|
||||
// UserOfToken returns the user associated with the token in request.
|
||||
// To check the user of a token or session, use SessionOf.
|
||||
func (auth *Auth) UserOfToken(r *http.Request) (user *AuthUser, err error) {
|
||||
// get the token object
|
||||
token, err := auth.Dependencies.Tokens.TokenOf(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue