Skip to content

Commit

Permalink
Merge pull request #325 from kthcloud/dev
Browse files Browse the repository at this point in the history
fix bugs with edge cases when fetching users
  • Loading branch information
saffronjam authored Dec 14, 2023
2 parents 7df895b + d9bb7ee commit fc8b8c2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions routers/api/v1/v1_user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,27 @@ func Get(c *gin.Context) {
context.ServerError(err, v1.InternalError)
return
}

if user == nil {
context.NotFound("User not found")
return
}
} else {
effectiveRole = config.Config.GetRole(user.EffectiveRole.Name)
user, err = usc.Get(requestURI.UserID, &user_service.GetUserOpts{})
if err != nil {
context.ServerError(err, v1.InternalError)
return
}
}

if user == nil {
context.NotFound("User not found")
return
if user == nil {
context.NotFound("User not found")
return
}

effectiveRole = config.Config.GetRole(user.EffectiveRole.Name)
if effectiveRole == nil {
effectiveRole = &roleModel.Role{}
}
}

usage, err := collectUsage(user.ID)
Expand Down

0 comments on commit fc8b8c2

Please sign in to comment.