提交 fd59cc62 编写于 作者: programor_guo's avatar programor_guo

demo modify

上级 6a8a0f22
......@@ -441,9 +441,6 @@ demo:
senderAuthorizationCode: "1gxyausfoevlzbfag"
smtpAddr: "smtp.qq.com"
smtpPort: 25
errMsg:
hasRegistered: "用户已经注册"
mailSendCodeErr: "邮件发送失败"
......@@ -39,13 +39,13 @@ func SendVerificationCode(c *gin.Context) {
_, err := im_mysql_model.GetRegister(account)
if err == nil {
log.NewError(params.OperationID, "The phone number has been registered", params)
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": getErrMsg(constant.HasRegistered)})
c.JSON(http.StatusOK, gin.H{"errCode": constant.HasRegistered, "errMsg": ""})
return
}
ok, err := db.DB.JudgeAccountEXISTS(account)
if ok || err != nil {
log.NewError(params.OperationID, "The phone number has been registered", params)
c.JSON(http.StatusOK, gin.H{"errCode": constant.RepeatSendCode, "errMsg": getErrMsg(constant.RepeatSendCode)})
c.JSON(http.StatusOK, gin.H{"errCode": constant.RepeatSendCode, "errMsg": ""})
return
}
log.InfoByKv("begin sendSms", account)
......@@ -67,7 +67,7 @@ func SendVerificationCode(c *gin.Context) {
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
log.ErrorByKv("send mail error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": getErrMsg(constant.MailSendCodeErr)})
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
return
}
} else {
......@@ -117,13 +117,3 @@ func CreateClient(accessKeyId *string, accessKeySecret *string) (result *dysmsap
result, err = dysmsapi20170525.NewClient(c)
return result, err
}
func getErrMsg(errCode int) string {
switch errCode {
case constant.HasRegistered:
return config.Config.Demo.ErrMsg.HasRegistered
case constant.MailSendCodeErr:
return config.Config.Demo.ErrMsg.MailSendCodeErr
default:
return ""
}
}
......@@ -22,6 +22,7 @@ type ParamsSetPassword struct {
Password string `json:"password"`
VerificationCode string `json:"verificationCode"`
Platform int32 `json:"platform" binding:"required,min=1,max=7"`
Ex string `json:"ex"`
OperationID string `json:"operationID" binding:"required"`
}
......@@ -68,7 +69,7 @@ func SetPassword(c *gin.Context) {
return
}
log.Info(params.OperationID, "begin store mysql", account, params.Password)
err = im_mysql_model.SetPassword(account, params.Password)
err = im_mysql_model.SetPassword(account, params.Password, params.Ex)
if err != nil {
log.NewError(params.OperationID, "set phone number password error", account, "err", err.Error())
c.JSON(http.StatusOK, gin.H{"errCode": constant.RegisterFailed, "errMsg": err.Error()})
......
......@@ -293,10 +293,6 @@ type config struct {
SmtpAddr string `yaml:"smtpAddr"`
SmtpPort int `yaml:"smtpPort"`
}
ErrMsg struct {
HasRegistered string `yaml:"hasRegistered"`
MailSendCodeErr string `yaml:"mailSendCodeErr"`
}
}
}
type PConversation struct {
......
......@@ -14,10 +14,11 @@ func GetRegister(account string) (*db.Register, error) {
return &r, dbConn.Table("registers").Where("account = ?",
account).Take(&r).Error
}
func SetPassword(account, password string) error {
func SetPassword(account, password, ex string) error {
r := db.Register{
Account: account,
Password: password,
Ex: ex,
}
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册