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
This commit is contained in:
Matt Baer 2020-02-08 14:46:05 -05:00
parent af14bcbb78
commit 666bd1b9d1
1 changed files with 5 additions and 1 deletions

View File

@ -187,7 +187,11 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
var err error var err error
p.User, err = app.db.GetUserForAuth(username) p.User, err = app.db.GetUserForAuth(username)
if err != nil { 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) flashes, _ := getSessionFlashes(app, w, r, nil)