summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-05-07 22:30:51 +0200
committerGitHub <noreply@github.com>2020-05-07 21:30:51 +0100
commitcd7fa15d1d3285bd918fea67276ea4bca194cc1d (patch)
tree944035f34df3f54b0898a46df2d3b4cfa9acc46c /models
parent79868d7096296f2afa4ccdc20cc69efac693b812 (diff)
downloadgitea-cd7fa15d1d3285bd918fea67276ea4bca194cc1d.tar.gz
gitea-cd7fa15d1d3285bd918fea67276ea4bca194cc1d.zip
Prevent multiple listings of organization when creating a repository (#11303) (#11325)
Backport #11303 Prevent multiple listings of organization when creating a repository (#11303) prevent double entries in results of GetOrgsCanCreateRepoByUserID I first try to only add GroupBy directly but xorm return broken user objects ... ... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs close #11258 Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models')
-rw-r--r--models/org.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/org.go b/models/org.go
index dbc71761f2..d00c2e1a54 100644
--- a/models/org.go
+++ b/models/org.go
@@ -470,12 +470,12 @@ func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) {
func GetOrgsCanCreateRepoByUserID(userID int64) ([]*User, error) {
orgs := make([]*User, 0, 10)
- return orgs, x.Join("INNER", "`team_user`", "`team_user`.org_id=`user`.id").
- Join("INNER", "`team`", "`team`.id=`team_user`.team_id").
- Where("`team_user`.uid=?", userID).
- And(builder.Eq{"`team`.authorize": AccessModeOwner}.Or(builder.Eq{"`team`.can_create_org_repo": true})).
- Desc("`user`.updated_unix").
- Find(&orgs)
+ return orgs, x.Where(builder.In("id", builder.Select("`user`.id").From("`user`").
+ Join("INNER", "`team_user`", "`team_user`.org_id = `user`.id").
+ Join("INNER", "`team`", "`team`.id = `team_user`.team_id").
+ Where(builder.Eq{"`team_user`.uid": userID}).
+ And(builder.Eq{"`team`.authorize": AccessModeOwner}.Or(builder.Eq{"`team`.can_create_org_repo": true})))).
+ Desc("`user`.updated_unix").Find(&orgs)
}
// GetOrgUsersByUserID returns all organization-user relations by user ID.