feat: Add slider verification code

This commit is contained in:
EUForest
2026-03-23 02:42:12 +08:00
parent bc721b0ba6
commit 7fe7243c24
21 changed files with 987 additions and 349 deletions
@@ -0,0 +1,26 @@
package admin
import (
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/auth/admin"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/result"
)
// Verify slider captcha
func AdminSliderVerifyCaptchaHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.SliderVerifyCaptchaRequest
_ = c.ShouldBind(&req)
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
l := admin.NewAdminSliderVerifyCaptchaLogic(c.Request.Context(), svcCtx)
resp, err := l.AdminSliderVerifyCaptcha(&req)
result.HttpResult(c, resp, err)
}
}
@@ -0,0 +1,26 @@
package auth
import (
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/auth"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/result"
)
// Verify slider captcha
func SliderVerifyCaptchaHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.SliderVerifyCaptchaRequest
_ = c.ShouldBind(&req)
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
l := auth.NewSliderVerifyCaptchaLogic(c.Request.Context(), svcCtx)
resp, err := l.SliderVerifyCaptcha(&req)
result.HttpResult(c, resp, err)
}
}
@@ -0,0 +1,26 @@
package auth
import (
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/auth"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/result"
)
// User Telephone register
func TelephoneRegisterHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.TelephoneRegisterRequest
_ = c.ShouldBind(&req)
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
l := auth.NewTelephoneRegisterLogic(c.Request.Context(), svcCtx)
resp, err := l.TelephoneRegister(&req)
result.HttpResult(c, resp, err)
}
}
+10 -4
View File
@@ -674,6 +674,9 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
// Generate captcha
authGroupRouter.POST("/captcha/generate", auth.GenerateCaptchaHandler(serverCtx))
// Verify slider captcha
authGroupRouter.POST("/captcha/slider/verify", auth.SliderVerifyCaptchaHandler(serverCtx))
// Check user is exist
authGroupRouter.GET("/check", auth.CheckUserHandler(serverCtx))
@@ -693,12 +696,12 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
authGroupRouter.POST("/register", auth.UserRegisterHandler(serverCtx))
// User Telephone register
authGroupRouter.POST("/register/telephone", auth.TelephoneUserRegisterHandler(serverCtx))
authGroupRouter.POST("/register/telephone", auth.TelephoneRegisterHandler(serverCtx))
// Reset password
authGroupRouter.POST("/reset", auth.ResetPasswordHandler(serverCtx))
// Reset password
// Reset password by telephone
authGroupRouter.POST("/reset/telephone", auth.TelephoneResetPasswordHandler(serverCtx))
}
@@ -709,6 +712,9 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
// Generate captcha
authAdminGroupRouter.POST("/captcha/generate", authAdmin.AdminGenerateCaptchaHandler(serverCtx))
// Verify slider captcha
authAdminGroupRouter.POST("/captcha/slider/verify", authAdmin.AdminSliderVerifyCaptchaHandler(serverCtx))
// Admin login
authAdminGroupRouter.POST("/login", authAdmin.AdminLoginHandler(serverCtx))
@@ -1008,10 +1014,10 @@ func RegisterHandlers(router *gin.Engine, serverCtx *svc.ServiceContext) {
serverGroupRouter.GET("/user", server.GetServerUserListHandler(serverCtx))
}
serverV2GroupRouter := router.Group("/v2/server")
serverGroupRouterV2 := router.Group("/v2/server")
{
// Get Server Protocol Config
serverV2GroupRouter.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx))
serverGroupRouterV2.GET("/:server_id", server.QueryServerProtocolConfigHandler(serverCtx))
}
}