diff options
author | 6543 <6543@obermui.de> | 2020-02-04 15:27:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-04 16:27:18 +0200 |
commit | d4096ab6a284ce2c36305428459fd75dcb2e4ee5 (patch) | |
tree | bf549fa86daa1262aa64e3d823addee2c3e6d5b1 /models/user.go | |
parent | b3c72a7c4a935e805b87ff2e1911429628ace7c5 (diff) | |
download | gitea-d4096ab6a284ce2c36305428459fd75dcb2e4ee5.tar.gz gitea-d4096ab6a284ce2c36305428459fd75dcb2e4ee5.zip |
Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134)
* add check to DeleteUser
* add check to DeleteOrganization
* add Test
* remove redundancy (deleteOrg is only used in DeleteOrganization)
* Update models/org.go
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index fda3bb5eab..213b5f76ab 100644 --- a/models/user.go +++ b/models/user.go @@ -1244,6 +1244,10 @@ func deleteUser(e *xorm.Session, u *User) error { // DeleteUser completely and permanently deletes everything of a user, // but issues/comments/pulls will be kept and shown as someone has been deleted. func DeleteUser(u *User) (err error) { + if u.IsOrganization() { + return fmt.Errorf("%s is an organization not a user", u.Name) + } + sess := x.NewSession() defer sess.Close() if err = sess.Begin(); err != nil { |