@@ -176,10 +176,11 @@ func Routes(ctx gocontext.Context) *web.Route {
176
176
// registerRoutes register routes
177
177
func registerRoutes (m * web.Route ) {
178
178
reqSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : true })
179
+ reqSignOut := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignOutRequired : true })
180
+ // TODO: rename them to "optSignIn", which means that the "sign-in" could be optional, depends on the VerifyOptions (RequireSignInView)
179
181
ignSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView })
180
182
ignExploreSignIn := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignInRequired : setting .Service .RequireSignInView || setting .Service .Explore .RequireSigninView })
181
183
ignSignInAndCsrf := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {DisableCSRF : true })
182
- reqSignOut := auth_service .VerifyAuthWithOptions (& auth_service.VerifyOptions {SignOutRequired : true })
183
184
validation .AddBindingRules ()
184
185
185
186
linkAccountEnabled := func (ctx * context.Context ) {
@@ -489,7 +490,6 @@ func registerRoutes(m *web.Route) {
489
490
}, reqSignIn , ctxDataSet ("PageIsUserSettings" , true , "AllThemes" , setting .UI .Themes , "EnablePackages" , setting .Packages .Enabled ))
490
491
491
492
m .Group ("/user" , func () {
492
- // r.Get("/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
493
493
m .Get ("/activate" , auth .Activate )
494
494
m .Post ("/activate" , auth .ActivatePost )
495
495
m .Any ("/activate_email" , auth .ActivateEmail )
@@ -809,7 +809,7 @@ func registerRoutes(m *web.Route) {
809
809
}, reqPackageAccess (perm .AccessModeWrite ))
810
810
})
811
811
})
812
- }, ignSignIn , context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
812
+ }, context .PackageAssignment (), reqPackageAccess (perm .AccessModeRead ))
813
813
}
814
814
815
815
m .Group ("/projects" , func () {
@@ -848,7 +848,7 @@ func registerRoutes(m *web.Route) {
848
848
m .Group ("" , func () {
849
849
m .Get ("/code" , user .CodeSearch )
850
850
}, reqUnitAccess (unit .TypeCode , perm .AccessModeRead ))
851
- }, context_service .UserAssignmentWeb (), context .OrgAssignment ())
851
+ }, ignSignIn , context_service .UserAssignmentWeb (), context .OrgAssignment ()) // for "/{username}/-" (packages, projects, code )
852
852
853
853
// ***** Release Attachment Download without Signin
854
854
m .Get ("/{username}/{reponame}/releases/download/{vTag}/{fileName}" , ignSignIn , context .RepoAssignment , repo .MustBeNotEmpty , repo .RedirectDownload )
@@ -940,7 +940,7 @@ func registerRoutes(m *web.Route) {
940
940
941
941
m .Post ("/{username}/{reponame}/action/{action}" , reqSignIn , context .RepoAssignment , context .UnitTypes (), repo .Action )
942
942
943
- // Grouping for those endpoints not requiring authentication
943
+ // Grouping for those endpoints not requiring authentication (but should respect ignSignIn)
944
944
m .Group ("/{username}/{reponame}" , func () {
945
945
m .Group ("/milestone" , func () {
946
946
m .Get ("/{id}" , repo .MilestoneIssuesAndPulls )
@@ -953,14 +953,14 @@ func registerRoutes(m *web.Route) {
953
953
})
954
954
m .Get ("/compare" , repo .MustBeNotEmpty , reqRepoCodeReader , repo .SetEditorconfigIfExists , ignSignIn , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff )
955
955
m .Combo ("/compare/*" , repo .MustBeNotEmpty , reqRepoCodeReader , repo .SetEditorconfigIfExists ).
956
- Get (ignSignIn , repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
956
+ Get (repo .SetDiffViewStyle , repo .SetWhitespaceBehavior , repo .CompareDiff ).
957
957
Post (reqSignIn , context .RepoMustNotBeArchived (), reqRepoPullsReader , repo .MustAllowPulls , web .Bind (forms.CreateIssueForm {}), repo .SetWhitespaceBehavior , repo .CompareAndPullRequestPost )
958
958
m .Group ("/{type:issues|pulls}" , func () {
959
959
m .Group ("/{index}" , func () {
960
960
m .Get ("/info" , repo .GetIssueInfo )
961
961
})
962
962
})
963
- }, context .RepoAssignment , context .UnitTypes ())
963
+ }, ignSignIn , context .RepoAssignment , context .UnitTypes ()) // for "/{username}/{reponame}" which doesn't require authentication
964
964
965
965
// Grouping for those endpoints that do require authentication
966
966
m .Group ("/{username}/{reponame}" , func () {
0 commit comments