Skip to content

Commit 3cc3ce9

Browse files
a1012112796zeripath
andcommitted
fix permisson check
Signed-off-by: a1012112796 <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent be0c1f9 commit 3cc3ce9

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

modules/context/org.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"code.gitea.io/gitea/models/perm"
1313
user_model "code.gitea.io/gitea/models/user"
1414
"code.gitea.io/gitea/modules/setting"
15+
"code.gitea.io/gitea/modules/structs"
1516
)
1617

1718
// Organization contains organization context
@@ -69,6 +70,20 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
6970
return
7071
}
7172
org := ctx.Org.Organization
73+
74+
// Handle Visibility
75+
if org.Visibility != structs.VisibleTypePublic && !ctx.IsSigned {
76+
// We must be signed in to see limited or private organizations
77+
ctx.NotFound("OrgAssignment", err)
78+
return
79+
}
80+
81+
if org.Visibility == structs.VisibleTypePrivate {
82+
requireMember = true
83+
} else if ctx.IsSigned && ctx.Doer.IsRestricted {
84+
requireMember = true
85+
}
86+
7287
ctx.ContextUser = org.AsUser()
7388
ctx.Data["Org"] = org
7489

routers/web/org/home.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ func Home(ctx *context.Context) {
3939

4040
org := ctx.Org.Organization
4141

42-
if !organization.HasOrgOrUserVisible(ctx, org.AsUser(), ctx.Doer) {
43-
ctx.NotFound("HasOrgOrUserVisible", nil)
44-
return
45-
}
46-
4742
ctx.Data["PageIsUserProfile"] = true
4843
ctx.Data["Title"] = org.DisplayName()
4944
if len(org.Description) != 0 {

0 commit comments

Comments
 (0)