Fetch user to determine role
This commit is contained in:
@@ -143,9 +143,18 @@ func (s *Server) TokenHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
u, err := s.userClient.GetUser(userIdentifier)
|
||||
if err != nil {
|
||||
WriteError(w, auth.ErrorResponse{
|
||||
Status: http.StatusUnauthorized,
|
||||
Message: fmt.Sprintf("Unable to get user details: %s", err),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
exp := time.Now().Add(DefaultTokenDuration)
|
||||
claims := auth.MicrofilmClaims{
|
||||
Role: auth.RoleUser,
|
||||
Role: u.Role,
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
Issuer: "microfilm",
|
||||
Subject: userIdentifier,
|
||||
|
Reference in New Issue
Block a user