Skip to content

Commit

Permalink
fix permisson check
Browse files Browse the repository at this point in the history
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
a1012112796 and zeripath committed Jul 14, 2022
1 parent be0c1f9 commit 3cc3ce9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 15 additions & 0 deletions modules/context/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models/perm"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
)

// Organization contains organization context
Expand Down Expand Up @@ -69,6 +70,20 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
return
}
org := ctx.Org.Organization

// Handle Visibility
if org.Visibility != structs.VisibleTypePublic && !ctx.IsSigned {
// We must be signed in to see limited or private organizations
ctx.NotFound("OrgAssignment", err)
return
}

if org.Visibility == structs.VisibleTypePrivate {
requireMember = true
} else if ctx.IsSigned && ctx.Doer.IsRestricted {
requireMember = true
}

ctx.ContextUser = org.AsUser()
ctx.Data["Org"] = org

Expand Down
5 changes: 0 additions & 5 deletions routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ func Home(ctx *context.Context) {

org := ctx.Org.Organization

if !organization.HasOrgOrUserVisible(ctx, org.AsUser(), ctx.Doer) {
ctx.NotFound("HasOrgOrUserVisible", nil)
return
}

ctx.Data["PageIsUserProfile"] = true
ctx.Data["Title"] = org.DisplayName()
if len(org.Description) != 0 {
Expand Down

0 comments on commit 3cc3ce9

Please sign in to comment.