aboutsummaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2019-08-02 18:06:28 +0200
committertechknowlogick <techknowlogick@gitea.io>2019-08-02 12:06:27 -0400
commit76408d50fb338e9239ee06bb26eec28453167300 (patch)
tree552f49cb095e9744c11f71dba9a3910a7d0ceb18 /models/org.go
parent3566d2c860b0ad3ab7d6d5fb1490eb9a5b5f5974 (diff)
downloadgitea-76408d50fb338e9239ee06bb26eec28453167300.tar.gz
gitea-76408d50fb338e9239ee06bb26eec28453167300.zip
org/members: display 2FA members states + optimize sql requests (#7621)
* org/members: display 2FA state * fix comment typo * lay down UserList bases * add basic test for previous methods * add comment for UserList type * add valid two-fa account * test new UserList methods * optimize MembersIsPublic by side loading info on GetMembers + fix integrations tests * respect fmt rules * use map for data * Optimize GetTwoFaStatus * rewrite by using existing sub func * Optimize IsUserOrgOwner * remove un-used code * tests: cover empty org + fix import order * tests: add ErrTeamNotExist path * tests: fix wrong expected result
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/org.go b/models/org.go
index d86109de57..7032f6698e 100644
--- a/models/org.go
+++ b/models/org.go
@@ -72,9 +72,12 @@ func (org *User) GetMembers() error {
}
var ids = make([]int64, len(ous))
+ var idsIsPublic = make(map[int64]bool, len(ous))
for i, ou := range ous {
ids[i] = ou.UID
+ idsIsPublic[ou.UID] = ou.IsPublic
}
+ org.MembersIsPublic = idsIsPublic
org.Members, err = GetUsersByIDs(ids)
return err
}
@@ -298,15 +301,13 @@ type OrgUser struct {
}
func isOrganizationOwner(e Engine, orgID, uid int64) (bool, error) {
- ownerTeam := &Team{
- OrgID: orgID,
- Name: ownerTeamName,
- }
- if has, err := e.Get(ownerTeam); err != nil {
+ ownerTeam, err := getOwnerTeam(e, orgID)
+ if err != nil {
+ if err == ErrTeamNotExist {
+ log.Error("Organization does not have owner team: %d", orgID)
+ return false, nil
+ }
return false, err
- } else if !has {
- log.Error("Organization does not have owner team: %d", orgID)
- return false, nil
}
return isTeamMember(e, orgID, ownerTeam.ID, uid)
}