aboutsummaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-02-04 15:27:18 +0100
committerGitHub <noreply@github.com>2020-02-04 16:27:18 +0200
commitd4096ab6a284ce2c36305428459fd75dcb2e4ee5 (patch)
treebf549fa86daa1262aa64e3d823addee2c3e6d5b1 /models/org.go
parentb3c72a7c4a935e805b87ff2e1911429628ace7c5 (diff)
downloadgitea-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/org.go')
-rw-r--r--models/org.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/models/org.go b/models/org.go
index 176a51ef94..4961db2ac7 100644
--- a/models/org.go
+++ b/models/org.go
@@ -256,6 +256,10 @@ func CountOrganizations() int64 {
// DeleteOrganization completely and permanently deletes everything of organization.
func DeleteOrganization(org *User) (err error) {
+ if !org.IsOrganization() {
+ return fmt.Errorf("%s is a user not an organization", org.Name)
+ }
+
sess := x.NewSession()
defer sess.Close()
@@ -275,10 +279,6 @@ func DeleteOrganization(org *User) (err error) {
}
func deleteOrg(e *xorm.Session, u *User) error {
- if !u.IsOrganization() {
- return fmt.Errorf("You can't delete none organization user: %s", u.Name)
- }
-
// Check ownership of repository.
count, err := getRepositoryCount(e, u)
if err != nil {