diff options
author | zeripath <art27@cantab.net> | 2022-09-04 17:17:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-04 12:17:35 -0400 |
commit | ea416d7d0edb1a291e8f2019449abce3d05c9b50 (patch) | |
tree | 05d3e9fb184a526fe8b1a07cfcc423377b4ab58c | |
parent | 0db6add5c0df9dd227f730cf29804c41bd3df887 (diff) | |
download | gitea-ea416d7d0edb1a291e8f2019449abce3d05c9b50.tar.gz gitea-ea416d7d0edb1a291e8f2019449abce3d05c9b50.zip |
Redirect if user does not exist on admin pages (#20981) (#21059)
Backport #20981
When on /admin/users/ endpoints if the user is no longer in the DB,
redirect instead of causing a http 500.
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
-rw-r--r-- | routers/web/admin/users.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index c37ecfd71e..39b212bbc3 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -209,7 +209,11 @@ func NewUserPost(ctx *context.Context) { func prepareUserInfo(ctx *context.Context) *user_model.User { u, err := user_model.GetUserByID(ctx.ParamsInt64(":userid")) if err != nil { - ctx.ServerError("GetUserByID", err) + if user_model.IsErrUserNotExist(err) { + ctx.Redirect(setting.AppSubURL + "/admin/users") + } else { + ctx.ServerError("GetUserByID", err) + } return nil } ctx.Data["User"] = u |