验证码测试
This commit is contained in:
parent
b6f28d7266
commit
1870c4979d
@ -922,7 +922,7 @@ func Destroy() {
|
||||
}
|
||||
}
|
||||
|
||||
func GeneratedCode(Phone string) error {
|
||||
func GeneratedCode(Phone string) (string, error) {
|
||||
Code := GoUtil.Rand6DigitNumber()
|
||||
log.Debug("生成验证码: %s", Code)
|
||||
key := "Code_" + Phone
|
||||
@ -935,7 +935,8 @@ func GeneratedCode(Phone string) error {
|
||||
if err != nil {
|
||||
log.Error("发送验证码失败: %v", err)
|
||||
}
|
||||
return err
|
||||
// TODO 测试用
|
||||
return Code, err
|
||||
}
|
||||
|
||||
func VerifyCode(Phone, Code string) error {
|
||||
|
||||
@ -105,11 +105,12 @@ func HandleClientReq(args []interface{}) {
|
||||
case "ReqLoginCode":
|
||||
Detail := &msg.ReqLoginCode{}
|
||||
proto.Unmarshal(buf, Detail)
|
||||
err := GeneratedCode(Detail.TelPhone)
|
||||
Code, err := GeneratedCode(Detail.TelPhone)
|
||||
ResLoginCode := &msg.ResLoginCode{}
|
||||
if err != nil {
|
||||
ResLoginCode.ResultCode = MergeConst.Protocol_Error_Account_Code_Error
|
||||
ResLoginCode.Msg = err.Error()
|
||||
ResLoginCode.Code = Code
|
||||
}
|
||||
data, _ := proto.Marshal(ResLoginCode)
|
||||
G_GameLogicPtr.PackResInfo(a, "ResLoginCode", data)
|
||||
|
||||
@ -1928,6 +1928,7 @@ type ResLoginCode struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ResultCode int32 `protobuf:"varint,1,opt,name=ResultCode,proto3" json:"ResultCode,omitempty"` // 0 成功 其他失败
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` // 错误信息
|
||||
Code string `protobuf:"bytes,3,opt,name=Code,proto3" json:"Code,omitempty"` // 验证码 TODO 测试
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -1976,6 +1977,13 @@ func (x *ResLoginCode) GetMsg() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ResLoginCode) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ReqId2Verify struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` // 身份证号码
|
||||
@ -23410,12 +23418,13 @@ const file_proto_Gameapi_proto_rawDesc = "" +
|
||||
"\x06Device\x18\x04 \x01(\tR\x06Device\x12(\n" +
|
||||
"\x04type\x18\x05 \x01(\x0e2\x14.tutorial.LOGIN_TYPER\x04type\"*\n" +
|
||||
"\fReqLoginCode\x12\x1a\n" +
|
||||
"\bTelPhone\x18\x01 \x01(\tR\bTelPhone\"@\n" +
|
||||
"\bTelPhone\x18\x01 \x01(\tR\bTelPhone\"T\n" +
|
||||
"\fResLoginCode\x12\x1e\n" +
|
||||
"\n" +
|
||||
"ResultCode\x18\x01 \x01(\x05R\n" +
|
||||
"ResultCode\x12\x10\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\"2\n" +
|
||||
"\x03Msg\x18\x02 \x01(\tR\x03Msg\x12\x12\n" +
|
||||
"\x04Code\x18\x03 \x01(\tR\x04Code\"2\n" +
|
||||
"\fReqId2Verify\x12\x0e\n" +
|
||||
"\x02Id\x18\x01 \x01(\tR\x02Id\x12\x12\n" +
|
||||
"\x04Name\x18\x02 \x01(\tR\x04Name\"T\n" +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user