mirror of
https://github.com/go-gitea/gitea
synced 2025-12-07 13:28:25 +00:00
Merge remote-tracking branch 'upstream/master' into team-grant-all-repos
# Conflicts: # models/migrations/migrations.go # models/migrations/v90.go # models/repo.go
This commit is contained in:
+14
-17
@@ -6,24 +6,19 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
|
||||
"github.com/Unknwon/com"
|
||||
"github.com/go-xorm/xorm"
|
||||
"github.com/unknwon/com"
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrTeamNotExist team does not exist
|
||||
ErrTeamNotExist = errors.New("Team does not exist")
|
||||
)
|
||||
|
||||
// IsOwnedBy returns true if given user is in the owner team.
|
||||
func (org *User) IsOwnedBy(uid int64) (bool, error) {
|
||||
return IsOrganizationOwner(org.ID, uid)
|
||||
@@ -75,9 +70,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
|
||||
}
|
||||
@@ -302,15 +300,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 IsErrTeamNotExist(err) {
|
||||
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)
|
||||
}
|
||||
@@ -483,8 +479,9 @@ func AddOrgUser(orgID, uid int64) error {
|
||||
}
|
||||
|
||||
ou := &OrgUser{
|
||||
UID: uid,
|
||||
OrgID: orgID,
|
||||
UID: uid,
|
||||
OrgID: orgID,
|
||||
IsPublic: setting.Service.DefaultOrgMemberVisible,
|
||||
}
|
||||
|
||||
if _, err := sess.Insert(ou); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user