Skip to content

Commit

Permalink
Move code from module to service (#24287)
Browse files Browse the repository at this point in the history
The code should not be in `modules/` but `services/`.

Reference:
#24257 (comment)
  • Loading branch information
KN4CK3R authored Apr 23, 2023
1 parent b2248d2 commit 55a600f
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 201 deletions.
194 changes: 0 additions & 194 deletions modules/context/auth.go

This file was deleted.

2 changes: 1 addition & 1 deletion routers/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}))

Expand Down
12 changes: 6 additions & 6 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
Loading

0 comments on commit 55a600f

Please sign in to comment.