Skip to content

Commit

Permalink
website/admin: clarify user variables in getProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Wessie committed Apr 26, 2024
1 parent 4f85d9a commit 0a9a3bc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions website/admin/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func (s *State) getProfile(w http.ResponseWriter, r *http.Request) error {
ctx := r.Context()

user := middleware.UserFromContext(ctx)
if user == nil {
panic("admin request with no user")
}
// the user we're viewing
toView := *user

// if admin, they can see other users, check if that is the case
if user.UserPermissions.Has(radio.PermAdmin) {
Expand All @@ -161,11 +166,11 @@ func (s *State) getProfile(w http.ResponseWriter, r *http.Request) error {
if err != nil {
return errors.E(op, err)
}
user = other
toView = *other
}
}

input, err := NewProfileInput(*user, r)
input, err := NewProfileInput(toView, r)
if err != nil {
return errors.E(op, err)
}
Expand Down

0 comments on commit 0a9a3bc

Please sign in to comment.