hi-server/internal/handler/common/checkverificationcodehandler.go
shanshanzhong a01570b59d
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 8m21s
fix gitea workflow path and runner label
2026-03-04 06:33:14 -08:00

36 lines
1.0 KiB
Go

package common
import (
"github.com/gin-gonic/gin"
"github.com/perfect-panel/server/internal/logic/common"
"github.com/perfect-panel/server/internal/svc"
"github.com/perfect-panel/server/internal/types"
"github.com/perfect-panel/server/pkg/constant"
"github.com/perfect-panel/server/pkg/result"
)
// Check verification code
func CheckVerificationCodeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
return func(c *gin.Context) {
var req types.CheckVerificationCodeRequest
_ = c.ShouldBind(&req)
validateErr := svcCtx.Validate(&req)
if validateErr != nil {
result.ParamErrorResult(c, validateErr)
return
}
l := common.NewCheckVerificationCodeLogic(c.Request.Context(), svcCtx)
useLatest := false
if value, ok := c.Request.Context().Value(constant.CtxKeyAPIVersionUseLatest).(bool); ok {
useLatest = value
}
resp, err := l.CheckVerificationCodeWithBehavior(&req, common.VerifyCodeCheckBehavior{
Source: "canonical",
Consume: useLatest,
})
result.HttpResult(c, resp, err)
}
}