Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 8m21s
36 lines
1.0 KiB
Go
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)
|
|
}
|
|
}
|