mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-30 00:00:02 +02:00
Prevent DeleteUser API abuse (#10125)
* fix & co * word suggestions from @jolheiser
This commit is contained in:
parent
29151b90c6
commit
ea50f60df2
2 changed files with 7 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue