mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-23 06:28:01 +02:00
Admin should not delete himself (#19423)
Admin should not be able to delete themselves. Also partially fix #15449
This commit is contained in:
@ -416,6 +416,15 @@ func DeleteUser(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// admin should not delete themself
|
||||
if u.ID == ctx.Doer.ID {
|
||||
ctx.Flash.Error(ctx.Tr("admin.users.cannot_delete_self"))
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users/" + url.PathEscape(ctx.Params(":userid")),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if err = user_service.DeleteUser(u); err != nil {
|
||||
switch {
|
||||
case models.IsErrUserOwnRepos(err):
|
||||
|
Reference in New Issue
Block a user