mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-22 22:18:02 +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:
@ -310,6 +310,12 @@ func DeleteUser(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
// admin should not delete themself
|
||||
if ctx.ContextUser.ID == ctx.Doer.ID {
|
||||
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("you cannot delete yourself"))
|
||||
return
|
||||
}
|
||||
|
||||
if err := user_service.DeleteUser(ctx.ContextUser); err != nil {
|
||||
if models.IsErrUserOwnRepos(err) ||
|
||||
models.IsErrUserHasOrgs(err) ||
|
||||
|
Reference in New Issue
Block a user