1.4.5.2
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package mobileverify
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type VerifyAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *VerifyAction) RunPost(params struct {
|
||||
Mobile string
|
||||
Code string
|
||||
}) {
|
||||
if len(params.Code) != userconfigs.MobileVerificationCodeLength ||
|
||||
!regexp.MustCompile(`^\d+$`).MatchString(params.Code) {
|
||||
this.FailField("code", "请输入正确的验证码")
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := this.RPC().UserMobileVerificationRPC().VerifyUserMobile(this.UserContext(), &pb.VerifyUserMobileRequest{
|
||||
Mobile: params.Mobile,
|
||||
Code: params.Code,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
if len(resp.ErrorCode) > 0 {
|
||||
this.FailField("code", resp.ErrorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user