summaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/models/org.go b/models/org.go
index 7f9e3cce5b..073b26c2f8 100644
--- a/models/org.go
+++ b/models/org.go
@@ -455,22 +455,22 @@ func getOwnedOrgsByUserID(sess *xorm.Session, userID int64) ([]*User, error) {
Find(&orgs)
}
-// HasOrgVisible tells if the given user can see the given org
-func HasOrgVisible(org, user *User) bool {
- return hasOrgVisible(x, org, user)
+// HasOrgOrUserVisible tells if the given user can see the given org or user
+func HasOrgOrUserVisible(org, user *User) bool {
+ return hasOrgOrUserVisible(x, org, user)
}
-func hasOrgVisible(e Engine, org, user *User) bool {
+func hasOrgOrUserVisible(e Engine, orgOrUser, user *User) bool {
// Not SignedUser
if user == nil {
- return org.Visibility == structs.VisibleTypePublic
+ return orgOrUser.Visibility == structs.VisibleTypePublic
}
- if user.IsAdmin {
+ if user.IsAdmin || orgOrUser.ID == user.ID {
return true
}
- if (org.Visibility == structs.VisibleTypePrivate || user.IsRestricted) && !org.hasMemberWithUserID(e, user.ID) {
+ if (orgOrUser.Visibility == structs.VisibleTypePrivate || user.IsRestricted) && !orgOrUser.hasMemberWithUserID(e, user.ID) {
return false
}
return true
@@ -483,7 +483,7 @@ func HasOrgsVisible(orgs []*User, user *User) bool {
}
for _, org := range orgs {
- if HasOrgVisible(org, user) {
+ if HasOrgOrUserVisible(org, user) {
return true
}
}