Skip to content

Commit ea416d7

Browse files
zeripathKN4CK3R
andauthored
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 <[email protected]>
1 parent 0db6add commit ea416d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

routers/web/admin/users.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ func NewUserPost(ctx *context.Context) {
209209
func prepareUserInfo(ctx *context.Context) *user_model.User {
210210
u, err := user_model.GetUserByID(ctx.ParamsInt64(":userid"))
211211
if err != nil {
212-
ctx.ServerError("GetUserByID", err)
212+
if user_model.IsErrUserNotExist(err) {
213+
ctx.Redirect(setting.AppSubURL + "/admin/users")
214+
} else {
215+
ctx.ServerError("GetUserByID", err)
216+
}
213217
return nil
214218
}
215219
ctx.Data["User"] = u

0 commit comments

Comments
 (0)