Skip to content

Commit

Permalink
Auth before parse middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
System-Glitch committed May 17, 2024
1 parent 20f4c9b commit 7284eb5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion http/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (

func Register(server *goyave.Server, router *goyave.Router) {
router.CORS(cors.Default())
router.GlobalMiddleware(log.CombinedLogMiddleware(), &parse.Middleware{})
router.GlobalMiddleware(log.CombinedLogMiddleware())

userService := server.Service(service.User).(*userservice.Service)
authenticator := auth.NewJWTAuthenticator(userService)
authMiddleware := auth.Middleware(authenticator)
router.GlobalMiddleware(authMiddleware)

router.GlobalMiddleware(&parse.Middleware{})

loginController := auth.NewJWTController(userService, "Password")
loginController.UsernameRequestField = "email"
router.Controller(loginController)
Expand Down

0 comments on commit 7284eb5

Please sign in to comment.