Return sms error message.

This commit is contained in:
Yang Luo
2021-05-14 18:19:47 +08:00
parent d361a39ffc
commit b7cbc0e015
4 changed files with 14 additions and 18 deletions

View File

@ -45,14 +45,14 @@ func (c *ApiController) SendVerificationCode() {
return
}
ret := "Invalid dest type."
msg := "Invalid dest type."
switch destType {
case "email":
if !util.IsEmailValid(dest) {
c.ResponseError("Invalid Email address")
return
}
ret = object.SendVerificationCodeToEmail(remoteAddr, dest)
msg = object.SendVerificationCodeToEmail(remoteAddr, dest)
case "phone":
if !util.IsPhoneCnValid(dest) {
c.ResponseError("Invalid phone number")
@ -64,17 +64,15 @@ func (c *ApiController) SendVerificationCode() {
phonePrefix = org.PhonePrefix
}
dest = fmt.Sprintf("+%s%s", phonePrefix, dest)
ret = object.SendVerificationCodeToPhone(remoteAddr, dest)
msg = object.SendVerificationCodeToPhone(remoteAddr, dest)
}
var status string
if len(ret) == 0 {
status = "ok"
} else {
status := "ok"
if msg != "" {
status = "error"
}
c.Data["json"] = Response{Status: status, Msg: ret}
c.Data["json"] = Response{Status: status, Msg: msg}
c.ServeJSON()
}