@@ -179,10 +179,11 @@ func Routes(ctx gocontext.Context) *web.Route {
179179// registerRoutes register routes
180180func registerRoutes (m * web.Route ) {
181181 reqSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : true })
182+ reqSignOut := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignOutRequired : true })
183+ // TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView)
182184 ignSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView })
183185 ignExploreSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView || setting .Service .Explore .RequireSigninView })
184186 ignSignInAndCsrf := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {DisableCSRF : true })
185- reqSignOut := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignOutRequired : true })
186187 validation .AddBindingRules ()
187188
188189 linkAccountEnabled := func (ctx * context.Context ) {
@@ -492,7 +493,6 @@ func registerRoutes(m *web.Route) {
492493 }, reqSignIn , ctxDataSet ("PageIsUserSettings" , true , "AllThemes" , setting .UI .Themes , "EnablePackages" , setting .Packages .Enabled ))
493494
494495 m .Group ("/user" , func () {
495- // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
496496 m .Get ("/activate" , auth .Activate )
497497 m .Post ("/activate" , auth .ActivatePost )
498498 m .Any ("/activate_email" , auth .ActivateEmail )
@@ -812,7 +812,7 @@ func registerRoutes(m *web.Route) {
812812 }, reqPackageAccess (perm .AccessModeWrite ))
813813 })
814814 })
815- }, ignSignIn , context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
815+ }, context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
816816 }
817817
818818 m .Group ("/projects" , func () {
@@ -851,7 +851,7 @@ func registerRoutes(m *web.Route) {
851851 m .Group ("" , func () {
852852 m .Get ("/code" , user .CodeSearch )
853853 }, reqUnitAccess (unit .TypeCode , perm .AccessModeRead ))
854- }, context_service .UserAssignmentWeb (), context .OrgAssignment ())
854+ }, ignSignIn , context_service .UserAssignmentWeb (), context .OrgAssignment ()) // for "/{username}/-" (packages, projects, code )
855855
856856 // ***** Release Attachment Download without Signin
857857 m .Get ("/{username}/{reponame}/releases/download/{vTag}/{fileName}" , ignSignIn , context .RepoAssignment , repo .MustBeNotEmpty , repo .RedirectDownload )
@@ -943,7 +943,6 @@ func registerRoutes(m *web.Route) {
943943
944944 m .Post ("/{username}/{reponame}/action/{action}" , reqSignIn , context .RepoAssignment , context .UnitTypes (), repo .Action )
945945
946- // Grouping for those endpoints not requiring authentication
947946 m .Group ("/{username}/{reponame}" , func () {
948947 m .Group ("/milestone" , func () {
949948 m .Get ("/{id}" , repo .MilestoneIssuesAndPulls )
@@ -956,14 +955,14 @@ func registerRoutes(m *web.Route) {
956955 })
957956 m .Get ("/compare" , repo .MustBeNotEmpty , reqRepoCodeReader , repo .SetEditorconfigIfExists , ignSignIn , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
958957 m .Combo ("/compare/*" , repo .MustBeNotEmpty , reqRepoCodeReader , repo .SetEditorconfigIfExists ).
959- Get (ignSignIn , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
958+ Get (repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
960959 Post (reqSignIn , context .RepoMustNotBeArchived (), reqRepoPullsReader , repo .MustAllowPulls , web .Bind (forms.CreateIssueForm {}), repo .SetWhitespaceBehavior , repo .CompareAndPullRequestPost )
961960 m .Group ("/{type:issues|pulls}" , func () {
962961 m .Group ("/{index}" , func () {
963962 m .Get ("/info" , repo .GetIssueInfo )
964963 })
965964 })
966- }, context .RepoAssignment , context .UnitTypes ())
965+ }, ignSignIn , context .RepoAssignment , context .UnitTypes ()) // for "/{username}/{reponame}"
967966
968967 // Grouping for those endpoints that do require authentication
969968 m .Group ("/{username}/{reponame}" , func () {
@@ -1093,7 +1092,7 @@ func registerRoutes(m *web.Route) {
10931092 repo .MustBeNotEmpty , reqRepoCodeReader , context .RepoRefByType (context .RepoRefTag , true ))
10941093 m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
10951094 repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
1096- }, reqSignIn , context .RepoAssignment , context .UnitTypes ())
1095+ }, ignSignIn , context .RepoAssignment , context .UnitTypes ())
10971096
10981097 // Releases
10991098 m .Group ("/{username}/{reponame}" , func () {
0 commit comments