Show correct error when user not found in admin panel

Previously, it would show a 500. This also logs the real reason if it's
not a "not found" error
pull/202/head
Matt Baer 5 years ago
parent af14bcbb78
commit 666bd1b9d1
  1. 6
      admin.go

@ -187,7 +187,11 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
var err error
p.User, err = app.db.GetUserForAuth(username)
if err != nil {
return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user: %v", err)}
if err == ErrUserNotFound {
return err
}
log.Error("Could not get user: %v", err)
return impart.HTTPError{http.StatusInternalServerError, err.Error()}
}
flashes, _ := getSessionFlashes(app, w, r, nil)

Loading…
Cancel
Save