Skip to content

Commit

Permalink
fix incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 29, 2023
1 parent 0bd05a9 commit b5f5936
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ func Routes(ctx gocontext.Context) *web.Route {
// registerRoutes register routes
func registerRoutes(m *web.Route) {
reqSignIn := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignInRequired: true})
reqSignOut := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignOutRequired: true})
// TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView)
ignSignIn := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignInRequired: setting.Service.RequireSignInView})
ignExploreSignIn := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignInRequired: setting.Service.RequireSignInView || setting.Service.Explore.RequireSigninView})
ignSignInAndCsrf := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{DisableCSRF: true})
reqSignOut := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignOutRequired: true})
validation.AddBindingRules()

linkAccountEnabled := func(ctx *context.Context) {
Expand Down Expand Up @@ -492,7 +493,6 @@ func registerRoutes(m *web.Route) {
}, reqSignIn, ctxDataSet("PageIsUserSettings", true, "AllThemes", setting.UI.Themes, "EnablePackages", setting.Packages.Enabled))

m.Group("/user", func() {
// r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
m.Get("/activate", auth.Activate)
m.Post("/activate", auth.ActivatePost)
m.Any("/activate_email", auth.ActivateEmail)
Expand Down Expand Up @@ -812,7 +812,7 @@ func registerRoutes(m *web.Route) {
}, reqPackageAccess(perm.AccessModeWrite))
})
})
}, ignSignIn, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
}, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
}

m.Group("/projects", func() {
Expand Down Expand Up @@ -851,7 +851,7 @@ func registerRoutes(m *web.Route) {
m.Group("", func() {
m.Get("/code", user.CodeSearch)
}, reqUnitAccess(unit.TypeCode, perm.AccessModeRead))
}, context_service.UserAssignmentWeb(), context.OrgAssignment())
}, ignSignIn, context_service.UserAssignmentWeb(), context.OrgAssignment()) // for "/{username}/-" (packages, projects, code)

// ***** Release Attachment Download without Signin
m.Get("/{username}/{reponame}/releases/download/{vTag}/{fileName}", ignSignIn, context.RepoAssignment, repo.MustBeNotEmpty, repo.RedirectDownload)
Expand Down Expand Up @@ -943,7 +943,6 @@ func registerRoutes(m *web.Route) {

m.Post("/{username}/{reponame}/action/{action}", reqSignIn, context.RepoAssignment, context.UnitTypes(), repo.Action)

// Grouping for those endpoints not requiring authentication
m.Group("/{username}/{reponame}", func() {
m.Group("/milestone", func() {
m.Get("/{id}", repo.MilestoneIssuesAndPulls)
Expand All @@ -956,14 +955,14 @@ func registerRoutes(m *web.Route) {
})
m.Get("/compare", repo.MustBeNotEmpty, reqRepoCodeReader, repo.SetEditorconfigIfExists, ignSignIn, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff)
m.Combo("/compare/*", repo.MustBeNotEmpty, reqRepoCodeReader, repo.SetEditorconfigIfExists).
Get(ignSignIn, repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff).
Get(repo.SetDiffViewStyle, repo.SetWhitespaceBehavior, repo.CompareDiff).
Post(reqSignIn, context.RepoMustNotBeArchived(), reqRepoPullsReader, repo.MustAllowPulls, web.Bind(forms.CreateIssueForm{}), repo.SetWhitespaceBehavior, repo.CompareAndPullRequestPost)
m.Group("/{type:issues|pulls}", func() {
m.Group("/{index}", func() {
m.Get("/info", repo.GetIssueInfo)
})
})
}, context.RepoAssignment, context.UnitTypes())
}, ignSignIn, context.RepoAssignment, context.UnitTypes()) // for "/{username}/{reponame}"

// Grouping for those endpoints that do require authentication
m.Group("/{username}/{reponame}", func() {
Expand Down Expand Up @@ -1093,7 +1092,7 @@ func registerRoutes(m *web.Route) {
repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true))
m.Post("/tags/delete", repo.DeleteTag, reqSignIn,
repo.MustBeNotEmpty, context.RepoMustNotBeArchived(), reqRepoCodeWriter, context.RepoRef())
}, reqSignIn, context.RepoAssignment, context.UnitTypes())
}, ignSignIn, context.RepoAssignment, context.UnitTypes())

// Releases
m.Group("/{username}/{reponame}", func() {
Expand Down

0 comments on commit b5f5936

Please sign in to comment.