Skip to content

Commit 0129e76

Browse files
authored
Prevent DeleteUser API abuse (#10125) (#10128)
* fix & co * word suggestions from @jolheiser
1 parent 6896dad commit 0129e76

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

routers/api/v1/admin/user.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package admin
77

88
import (
99
"errors"
10+
"fmt"
1011
"net/http"
1112

1213
"code.gitea.io/gitea/models"
@@ -226,6 +227,11 @@ func DeleteUser(ctx *context.APIContext) {
226227
return
227228
}
228229

230+
if u.IsOrganization() {
231+
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("%s is an organization not a user", u.Name))
232+
return
233+
}
234+
229235
if err := models.DeleteUser(u); err != nil {
230236
if models.IsErrUserOwnRepos(err) ||
231237
models.IsErrUserHasOrgs(err) {

routers/org/setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func SettingsDeleteAvatar(ctx *context.Context) {
115115
ctx.Redirect(ctx.Org.OrgLink + "/settings")
116116
}
117117

118-
// SettingsDelete response for delete repository
118+
// SettingsDelete response for deleting an organization
119119
func SettingsDelete(ctx *context.Context) {
120120
ctx.Data["Title"] = ctx.Tr("org.settings")
121121
ctx.Data["PageIsSettingsDelete"] = true

0 commit comments

Comments
 (0)