diff options
Diffstat (limited to 'routers/api/v1/admin/user.go')
-rw-r--r-- | routers/api/v1/admin/user.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 775802449a..6263a67048 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -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) || |