Prevent DeleteUser API abuse (#10125)

* fix & co

* word suggestions from @jolheiser
pull/10124/head^2
6543 5 years ago committed by GitHub
parent 29151b90c6
commit ea50f60df2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      routers/api/v1/admin/user.go
  2. 2
      routers/org/setting.go

@ -7,6 +7,7 @@ package admin
import (
"errors"
"fmt"
"net/http"
"code.gitea.io/gitea/models"
@ -227,6 +228,11 @@ func DeleteUser(ctx *context.APIContext) {
return
}
if u.IsOrganization() {
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("%s is an organization not a user", u.Name))
return
}
if err := models.DeleteUser(u); err != nil {
if models.IsErrUserOwnRepos(err) ||
models.IsErrUserHasOrgs(err) {

@ -115,7 +115,7 @@ func SettingsDeleteAvatar(ctx *context.Context) {
ctx.Redirect(ctx.Org.OrgLink + "/settings")
}
// SettingsDelete response for delete repository
// SettingsDelete response for deleting an organization
func SettingsDelete(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("org.settings")
ctx.Data["PageIsSettingsDelete"] = true

Loading…
Cancel
Save