summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-04-23 22:44:05 +0200
committerGitHub <noreply@github.com>2023-04-23 16:44:05 -0400
commit55a600fa4130b2708464be1c024c22ff46e6d4c0 (patch)
tree16c10ac2d7cce7a157b4c6a14df1e7e7620c774a /routers
parentb2248d25534029d4292c126fdde94bc8f84ea2c1 (diff)
downloadgitea-55a600fa4130b2708464be1c024c22ff46e6d4c0.tar.gz
gitea-55a600fa4130b2708464be1c024c22ff46e6d4c0.zip
Move code from module to service (#24287)
The code should not be in `modules/` but `services/`. Reference: https://github.com/go-gitea/gitea/pull/24257#discussion_r1174578230
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/api.go2
-rw-r--r--routers/web/web.go12
2 files changed, 7 insertions, 7 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 48311b3eee..ad68a33d6b 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -689,7 +689,7 @@ func Routes(ctx gocontext.Context) *web.Route {
// Get user from session if logged in.
m.Use(auth.APIAuth(group))
- m.Use(context.ToggleAPI(&context.ToggleOptions{
+ m.Use(auth.VerifyAuthWithOptionsAPI(&auth.VerifyOptions{
SignInRequired: setting.Service.RequireSignInView,
}))
diff --git a/routers/web/web.go b/routers/web/web.go
index 49ea63b191..88b6777d73 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -228,11 +228,11 @@ func Routes(ctx gocontext.Context) *web.Route {
// RegisterRoutes register routes
func RegisterRoutes(m *web.Route) {
- reqSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: true})
- ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView})
- ignExploreSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView || setting.Service.Explore.RequireSigninView})
- ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true})
- reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true})
+ reqSignIn := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignInRequired: true})
+ 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) {
@@ -551,7 +551,7 @@ func RegisterRoutes(m *web.Route) {
m.Get("/avatar/{hash}", user.AvatarByEmailHash)
- adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true})
+ adminReq := auth_service.VerifyAuthWithOptions(&auth_service.VerifyOptions{SignInRequired: true, AdminRequired: true})
// ***** START: Admin *****
m.Group("/admin", func() {