mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
Fix email must input bug in signup page.
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -254,14 +254,14 @@ class SignupPage extends React.Component {
|
|||||||
message: i18next.t("signup:Please input your Email!"),
|
message: i18next.t("signup:Please input your Email!"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
validator: (_, value) =>{
|
validator: (_, value) => {
|
||||||
if( Setting.EmailRegEx.test(this.state.email) ) {
|
if (this.state.email !== "" && !Setting.isValidEmail(this.state.email)) {
|
||||||
this.setState({validEmail: true})
|
this.setState({validEmail: false});
|
||||||
return Promise.resolve()
|
return Promise.reject(i18next.t("signup:The input is not valid Email!"));
|
||||||
} else {
|
|
||||||
this.setState({validEmail: false})
|
|
||||||
return Promise.reject(i18next.t("signup:The input is not valid Email!"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({validEmail: true});
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
@ -287,6 +287,60 @@ class SignupPage extends React.Component {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
} else if (signupItem.name === "Phone") {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Form.Item
|
||||||
|
name="phone"
|
||||||
|
key="phone"
|
||||||
|
label={i18next.t("general:Phone")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: required,
|
||||||
|
message: i18next.t("signup:Please input your phone number!"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: (_, value) =>{
|
||||||
|
if (this.state.phone !== "" && !Setting.isValidPhone(this.state.phone)) {
|
||||||
|
this.setState({validPhone: false});
|
||||||
|
return Promise.reject(i18next.t("signup:The input is not valid Phone!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({validPhone: true});
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
addonBefore={`+${this.state.application?.organizationObj.phonePrefix}`}
|
||||||
|
onChange={e => this.setState({phone: e.target.value})}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="phoneCode"
|
||||||
|
key="phoneCode"
|
||||||
|
label={i18next.t("code:Phone code")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: required,
|
||||||
|
message: i18next.t("code:Please input your phone verification code!"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<CountDownInput
|
||||||
|
disabled={!this.state.validPhone}
|
||||||
|
defaultButtonText={i18next.t("code:Send Code")}
|
||||||
|
onButtonClick={UserBackend.sendCode}
|
||||||
|
onButtonClickArgs={[this.state.phone, "phone", application.organizationObj.owner + "/" + application.organizationObj.name]}
|
||||||
|
coolDownTime={60}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
} else if (signupItem.name === "Password") {
|
} else if (signupItem.name === "Password") {
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@ -331,60 +385,6 @@ class SignupPage extends React.Component {
|
|||||||
<Input.Password />
|
<Input.Password />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)
|
)
|
||||||
} else if (signupItem.name === "Phone") {
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Form.Item
|
|
||||||
name="phone"
|
|
||||||
key="phone"
|
|
||||||
label={i18next.t("general:Phone")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: required,
|
|
||||||
message: i18next.t("signup:Please input your phone number!"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
validator: (_, value) =>{
|
|
||||||
if ( Setting.PhoneRegEx.test(this.state.phone)) {
|
|
||||||
this.setState({validPhone: true})
|
|
||||||
return Promise.resolve()
|
|
||||||
} else {
|
|
||||||
this.setState({validPhone: false})
|
|
||||||
return Promise.reject(i18next.t("signup:The input is not valid Phone!"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<Input
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
addonBefore={`+${this.state.application?.organizationObj.phonePrefix}`}
|
|
||||||
onChange={e => this.setState({phone: e.target.value})}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item
|
|
||||||
name="phoneCode"
|
|
||||||
key="phoneCode"
|
|
||||||
label={i18next.t("code:Phone code")}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: required,
|
|
||||||
message: i18next.t("code:Please input your phone verification code!"),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<CountDownInput
|
|
||||||
disabled={!this.state.validPhone}
|
|
||||||
defaultButtonText={i18next.t("code:Send Code")}
|
|
||||||
onButtonClick={UserBackend.sendCode}
|
|
||||||
onButtonClickArgs={[this.state.phone, "phone", application.organizationObj.owner + "/" + application.organizationObj.name]}
|
|
||||||
coolDownTime={60}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
</React.Fragment>
|
|
||||||
)
|
|
||||||
} else if (signupItem.name === "Agreement") {
|
} else if (signupItem.name === "Agreement") {
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
Reference in New Issue
Block a user