Refactor auth handler into separate account handler

This commit is contained in:
2026-04-29 17:36:04 +08:00
parent 697cc979c8
commit b0356bf103
5 changed files with 277 additions and 213 deletions

View File

@@ -10,19 +10,19 @@ import (
func setupProtectedRoutes(rg *gin.RouterGroup, webApp *app.WebApp) {
jwtSecret := []byte(webApp.Config.JWT.Secret)
authHandler := handler.NewAuthHandler(webApp.AuthService)
accountHandler := handler.NewAccountHandler(webApp.AuthService)
rg.Use(middleware.AuthRequired(jwtSecret))
account := rg.Group("/account")
{
account.GET("", authHandler.GetAccount)
account.GET("", accountHandler.GetAccount)
passkeys := account.Group("/passkeys")
{
passkeys.GET("", authHandler.ListPasskeys)
passkeys.POST("", authHandler.CreatePasskey)
passkeys.DELETE("/:id", authHandler.RevokePasskey)
passkeys.GET("", accountHandler.ListPasskeys)
passkeys.POST("", accountHandler.CreatePasskey)
passkeys.DELETE("/:id", accountHandler.RevokePasskey)
}
}
}