Files
waf-platform/EdgeUser/internal/web/actions/default/settings/mobile-verify/verify.go
2026-02-04 20:27:13 +08:00

42 lines
976 B
Go

// 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()
}