mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-08 00:50:28 +08:00
feat: improve verification error translation (#1660)
This commit is contained in:
@ -129,8 +129,8 @@ func (c *ApiController) Signup() {
|
|||||||
|
|
||||||
if application.IsSignupItemVisible("Email") && application.GetSignupItemRule("Email") != "No verification" && form.Email != "" {
|
if application.IsSignupItemVisible("Email") && application.GetSignupItemRule("Email") != "No verification" && form.Email != "" {
|
||||||
checkResult := object.CheckVerificationCode(form.Email, form.EmailCode, c.GetAcceptLanguage())
|
checkResult := object.CheckVerificationCode(form.Email, form.EmailCode, c.GetAcceptLanguage())
|
||||||
if len(checkResult) != 0 {
|
if checkResult.Code != object.VerificationSuccess {
|
||||||
c.ResponseError(c.T("account:Email: %s"), checkResult)
|
c.ResponseError(checkResult.Msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,8 +139,8 @@ func (c *ApiController) Signup() {
|
|||||||
if application.IsSignupItemVisible("Phone") && form.Phone != "" {
|
if application.IsSignupItemVisible("Phone") && form.Phone != "" {
|
||||||
checkPhone, _ = util.GetE164Number(form.Phone, form.CountryCode)
|
checkPhone, _ = util.GetE164Number(form.Phone, form.CountryCode)
|
||||||
checkResult := object.CheckVerificationCode(checkPhone, form.PhoneCode, c.GetAcceptLanguage())
|
checkResult := object.CheckVerificationCode(checkPhone, form.PhoneCode, c.GetAcceptLanguage())
|
||||||
if len(checkResult) != 0 {
|
if checkResult.Code != object.VerificationSuccess {
|
||||||
c.ResponseError(c.T("account:Phone: %s"), checkResult)
|
c.ResponseError(checkResult.Msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,8 +224,8 @@ func (c *ApiController) ResetEmailOrPhone() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if msg := object.CheckVerificationCode(checkDest, code, c.GetAcceptLanguage()); len(msg) != 0 {
|
if result := object.CheckVerificationCode(checkDest, code, c.GetAcceptLanguage()); result.Code != object.VerificationSuccess {
|
||||||
c.ResponseError(msg)
|
c.ResponseError(result.Msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "Email: %s",
|
|
||||||
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
"Get init score failed, error: %w": "Get init score failed, error: %w",
|
||||||
"Invalid information": "Invalid information",
|
"Invalid information": "Invalid information",
|
||||||
"Phone: %s": "Phone: %s",
|
|
||||||
"Please sign out first before signing in": "Please sign out first before signing in",
|
"Please sign out first before signing in": "Please sign out first before signing in",
|
||||||
"Please sign out first before signing up": "Please sign out first before signing up",
|
"Please sign out first before signing up": "Please sign out first before signing up",
|
||||||
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
"The application does not allow to sign up new account": "The application does not allow to sign up new account"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
"Unable to get the phone modify rule.": "Unable to get the phone modify rule.",
|
||||||
"Unknown type": "Unknown type",
|
"Unknown type": "Unknown type",
|
||||||
"Wrong parameter": "Wrong parameter",
|
"Wrong parameter": "Wrong parameter",
|
||||||
|
"Wrong verification code!": "Wrong verification code!",
|
||||||
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
"You should verify your code in %d min!": "You should verify your code in %d min!",
|
||||||
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
"the user does not exist, please sign up first": "the user does not exist, please sign up first"
|
||||||
},
|
},
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"account": {
|
"account": {
|
||||||
"Email: %s": "邮件: %s",
|
|
||||||
"Get init score failed, error: %w": "初始化分数失败: %w",
|
"Get init score failed, error: %w": "初始化分数失败: %w",
|
||||||
"Invalid information": "无效信息",
|
"Invalid information": "无效信息",
|
||||||
"Phone: %s": "手机号: %s",
|
|
||||||
"Please sign out first before signing in": "请在登录前先退出登录",
|
"Please sign out first before signing in": "请在登录前先退出登录",
|
||||||
"Please sign out first before signing up": "请在注册前先退出登录",
|
"Please sign out first before signing up": "请在注册前先退出登录",
|
||||||
"The application does not allow to sign up new account": "该应用不允许注册新用户"
|
"The application does not allow to sign up new account": "该应用不允许注册新用户"
|
||||||
@ -137,6 +135,7 @@
|
|||||||
"Unable to get the phone modify rule.": "无法获取手机号修改规则",
|
"Unable to get the phone modify rule.": "无法获取手机号修改规则",
|
||||||
"Unknown type": "未知类型",
|
"Unknown type": "未知类型",
|
||||||
"Wrong parameter": "参数错误",
|
"Wrong parameter": "参数错误",
|
||||||
|
"Wrong verification code!": "验证码错误!",
|
||||||
"You should verify your code in %d min!": "请在 %d 分钟内输入正确验证码",
|
"You should verify your code in %d min!": "请在 %d 分钟内输入正确验证码",
|
||||||
"the user does not exist, please sign up first": "用户不存在,请先注册"
|
"the user does not exist, please sign up first": "用户不存在,请先注册"
|
||||||
},
|
},
|
||||||
|
@ -84,15 +84,13 @@ func CheckUserSignup(application *Application, organization *Organization, usern
|
|||||||
if email == "" {
|
if email == "" {
|
||||||
if application.IsSignupItemRequired("Email") {
|
if application.IsSignupItemRequired("Email") {
|
||||||
return i18n.Translate(lang, "check:Email cannot be empty")
|
return i18n.Translate(lang, "check:Email cannot be empty")
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
if HasUserByField(organization.Name, "email", email) {
|
||||||
if HasUserByField(organization.Name, "email", email) {
|
return i18n.Translate(lang, "check:Email already exists")
|
||||||
return i18n.Translate(lang, "check:Email already exists")
|
} else if !util.IsEmailValid(email) {
|
||||||
} else if !util.IsEmailValid(email) {
|
return i18n.Translate(lang, "check:Email is invalid")
|
||||||
return i18n.Translate(lang, "check:Email is invalid")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,17 +98,15 @@ func CheckUserSignup(application *Application, organization *Organization, usern
|
|||||||
if phone == "" {
|
if phone == "" {
|
||||||
if application.IsSignupItemRequired("Phone") {
|
if application.IsSignupItemRequired("Phone") {
|
||||||
return i18n.Translate(lang, "check:Phone cannot be empty")
|
return i18n.Translate(lang, "check:Phone cannot be empty")
|
||||||
} else {
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
if HasUserByField(organization.Name, "phone", phone) {
|
||||||
if HasUserByField(organization.Name, "phone", phone) {
|
return i18n.Translate(lang, "check:Phone already exists")
|
||||||
return i18n.Translate(lang, "check:Phone already exists")
|
} else if !util.IsPhoneAllowInRegin(countryCode, organization.CountryCodes) {
|
||||||
} else if !util.IsPhoneAllowInRegin(countryCode, organization.CountryCodes) {
|
return i18n.Translate(lang, "check:Your region is not allow to signup by phone")
|
||||||
return i18n.Translate(lang, "check:Your region is not allow to signup by phone")
|
} else if !util.IsPhoneValid(phone, countryCode) {
|
||||||
} else if !util.IsPhoneValid(phone, countryCode) {
|
return i18n.Translate(lang, "check:Phone number is invalid")
|
||||||
return i18n.Translate(lang, "check:Phone number is invalid")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,16 @@ import (
|
|||||||
"github.com/xorm-io/core"
|
"github.com/xorm-io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type VerifyResult struct {
|
||||||
|
Code int
|
||||||
|
Msg string
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
wrongCode = "wrongCode"
|
VerificationSuccess int = 0
|
||||||
|
wrongCodeError = 1
|
||||||
|
noRecordError = 2
|
||||||
|
timeoutError = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
type VerificationRecord struct {
|
type VerificationRecord struct {
|
||||||
@ -150,11 +158,11 @@ func getVerificationRecord(dest string) *VerificationRecord {
|
|||||||
return &record
|
return &record
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckVerificationCode(dest, code, lang string) string {
|
func CheckVerificationCode(dest, code, lang string) *VerifyResult {
|
||||||
record := getVerificationRecord(dest)
|
record := getVerificationRecord(dest)
|
||||||
|
|
||||||
if record == nil {
|
if record == nil {
|
||||||
return i18n.Translate(lang, "verification:Code has not been sent yet!")
|
return &VerifyResult{noRecordError, i18n.Translate(lang, "verification:Code has not been sent yet!")}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout, err := conf.GetConfigInt64("verificationCodeTimeout")
|
timeout, err := conf.GetConfigInt64("verificationCodeTimeout")
|
||||||
@ -164,14 +172,14 @@ func CheckVerificationCode(dest, code, lang string) string {
|
|||||||
|
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
if now-record.Time > timeout*60 {
|
if now-record.Time > timeout*60 {
|
||||||
return fmt.Sprintf(i18n.Translate(lang, "verification:You should verify your code in %d min!"), timeout)
|
return &VerifyResult{timeoutError, fmt.Sprintf(i18n.Translate(lang, "verification:You should verify your code in %d min!"), timeout)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.Code != code {
|
if record.Code != code {
|
||||||
return wrongCode
|
return &VerifyResult{wrongCodeError, i18n.Translate(lang, "verification:Wrong verification code!")}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return &VerifyResult{VerificationSuccess, ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DisableVerificationCode(dest string) {
|
func DisableVerificationCode(dest string) {
|
||||||
@ -194,14 +202,14 @@ func CheckSigninCode(user *User, dest, code, lang string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := CheckVerificationCode(dest, code, lang)
|
result := CheckVerificationCode(dest, code, lang)
|
||||||
switch result {
|
switch result.Code {
|
||||||
case "":
|
case VerificationSuccess:
|
||||||
resetUserSigninErrorTimes(user)
|
resetUserSigninErrorTimes(user)
|
||||||
return ""
|
return ""
|
||||||
case wrongCode:
|
case wrongCodeError:
|
||||||
return recordSigninErrorInfo(user, lang)
|
return recordSigninErrorInfo(user, lang)
|
||||||
default:
|
default:
|
||||||
return result
|
return result.Msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ class SignupPage extends React.Component {
|
|||||||
} else if (signupItem.name === "Phone") {
|
} else if (signupItem.name === "Phone") {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Form.Item label={i18next.t("general:Phone")} required>
|
<Form.Item label={i18next.t("general:Phone")} required={required}>
|
||||||
<Input.Group compact>
|
<Input.Group compact>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="countryCode"
|
name="countryCode"
|
||||||
@ -398,6 +398,10 @@ class SignupPage extends React.Component {
|
|||||||
},
|
},
|
||||||
({getFieldValue}) => ({
|
({getFieldValue}) => ({
|
||||||
validator: (_, value) => {
|
validator: (_, value) => {
|
||||||
|
if (!required && value === "") {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
if (value !== "" && !Setting.isValidPhone(value, getFieldValue("countryCode"))) {
|
if (value !== "" && !Setting.isValidPhone(value, getFieldValue("countryCode"))) {
|
||||||
this.setState({validPhone: false});
|
this.setState({validPhone: false});
|
||||||
return Promise.reject(i18next.t("signup:The input is not valid Phone!"));
|
return Promise.reject(i18next.t("signup:The input is not valid Phone!"));
|
||||||
|
Reference in New Issue
Block a user