@@ -179,10 +179,11 @@ func Routes(ctx gocontext.Context) *web.Route {
179
179
// registerRoutes register routes
180
180
func registerRoutes (m * web.Route ) {
181
181
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)
182
184
ignSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView })
183
185
ignExploreSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView || setting .Service .Explore .RequireSigninView })
184
186
ignSignInAndCsrf := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {DisableCSRF : true })
185
- reqSignOut := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignOutRequired : true })
186
187
validation .AddBindingRules ()
187
188
188
189
linkAccountEnabled := func (ctx * context.Context ) {
@@ -492,7 +493,6 @@ func registerRoutes(m *web.Route) {
492
493
}, reqSignIn , ctxDataSet ("PageIsUserSettings" , true , "AllThemes" , setting .UI .Themes , "EnablePackages" , setting .Packages .Enabled ))
493
494
494
495
m .Group ("/user" , func () {
495
- // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
496
496
m .Get ("/activate" , auth .Activate )
497
497
m .Post ("/activate" , auth .ActivatePost )
498
498
m .Any ("/activate_email" , auth .ActivateEmail )
@@ -812,7 +812,7 @@ func registerRoutes(m *web.Route) {
812
812
}, reqPackageAccess (perm .AccessModeWrite ))
813
813
})
814
814
})
815
- }, ignSignIn , context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
815
+ }, context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
816
816
}
817
817
818
818
m .Group ("/projects" , func () {
@@ -851,7 +851,7 @@ func registerRoutes(m *web.Route) {
851
851
m .Group ("" , func () {
852
852
m .Get ("/code" , user .CodeSearch )
853
853
}, reqUnitAccess (unit .TypeCode , perm .AccessModeRead ))
854
- }, context_service .UserAssignmentWeb (), context .OrgAssignment ())
854
+ }, ignSignIn , context_service .UserAssignmentWeb (), context .OrgAssignment ()) // for "/{username}/-" (packages, projects, code )
855
855
856
856
// ***** Release Attachment Download without Signin
857
857
m .Get ("/{username}/{reponame}/releases/download/{vTag}/{fileName}" , ignSignIn , context .RepoAssignment , repo .MustBeNotEmpty , repo .RedirectDownload )
@@ -943,7 +943,6 @@ func registerRoutes(m *web.Route) {
943
943
944
944
m .Post ("/{username}/{reponame}/action/{action}" , reqSignIn , context .RepoAssignment , context .UnitTypes (), repo .Action )
945
945
946
- // Grouping for those endpoints not requiring authentication
947
946
m .Group ("/{username}/{reponame}" , func () {
948
947
m .Group ("/milestone" , func () {
949
948
m .Get ("/{id}" , repo .MilestoneIssuesAndPulls )
@@ -956,14 +955,14 @@ func registerRoutes(m *web.Route) {
956
955
})
957
956
m .Get ("/compare" , repo .MustBeNotEmpty , reqRepoCodeReader , repo .SetEditorconfigIfExists , ignSignIn , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
958
957
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 ).
960
959
Post (reqSignIn , context .RepoMustNotBeArchived (), reqRepoPullsReader , repo .MustAllowPulls , web .Bind (forms.CreateIssueForm {}), repo .SetWhitespaceBehavior , repo .CompareAndPullRequestPost )
961
960
m .Group ("/{type:issues|pulls}" , func () {
962
961
m .Group ("/{index}" , func () {
963
962
m .Get ("/info" , repo .GetIssueInfo )
964
963
})
965
964
})
966
- }, context .RepoAssignment , context .UnitTypes ())
965
+ }, ignSignIn , context .RepoAssignment , context .UnitTypes ()) // for "/{username}/{reponame}"
967
966
968
967
// Grouping for those endpoints that do require authentication
969
968
m .Group ("/{username}/{reponame}" , func () {
@@ -1093,7 +1092,7 @@ func registerRoutes(m *web.Route) {
1093
1092
repo .MustBeNotEmpty , reqRepoCodeReader , context .RepoRefByType (context .RepoRefTag , true ))
1094
1093
m .Post ("/tags/delete" , repo .DeleteTag , reqSignIn ,
1095
1094
repo .MustBeNotEmpty , context .RepoMustNotBeArchived (), reqRepoCodeWriter , context .RepoRef ())
1096
- }, reqSignIn , context .RepoAssignment , context .UnitTypes ())
1095
+ }, ignSignIn , context .RepoAssignment , context .UnitTypes ())
1097
1096
1098
1097
// Releases
1099
1098
m .Group ("/{username}/{reponame}" , func () {
0 commit comments