feat: add rule option for phone in application's signup page (#1745)

This commit is contained in:
wht 2023-04-16 20:34:06 +08:00 committed by GitHub
parent 7edaeafea5
commit 5c26335fd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 20 deletions

View File

@ -137,7 +137,7 @@ func (c *ApiController) Signup() {
}
var checkPhone string
if application.IsSignupItemVisible("Phone") && form.Phone != "" {
if application.IsSignupItemVisible("Phone") && application.GetSignupItemRule("Phone") != "No verification" && form.Phone != "" {
checkPhone, _ = util.GetE164Number(form.Phone, form.CountryCode)
checkResult := object.CheckVerificationCode(checkPhone, form.PhoneCode, c.GetAcceptLanguage())
if checkResult.Code != object.VerificationSuccess {

View File

@ -68,7 +68,7 @@ class ResultPage extends React.Component {
if (linkInStorage !== null && linkInStorage !== "") {
Setting.goToLink(linkInStorage);
} else {
Setting.redirectToLoginPage(application);
Setting.redirectToLoginPage(application, this.props.history);
}
}}>
{i18next.t("login:Sign In")}

View File

@ -408,24 +408,27 @@ class SignupPage extends React.Component {
</Form.Item>
</Input.Group>
</Form.Item>
<Form.Item
name="phoneCode"
label={i18next.t("code:Phone code")}
rules={[
{
required: required,
message: i18next.t("code:Please input your phone verification code!"),
},
]}
>
<SendCodeInput
disabled={!this.state.validPhone}
method={"signup"}
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(application)]}
application={application}
countryCode={this.form.current?.getFieldValue("countryCode")}
/>
</Form.Item>
{
signupItem.rule !== "No verification" &&
<Form.Item
name="phoneCode"
label={i18next.t("code:Phone code")}
rules={[
{
required: required,
message: i18next.t("code:Please input your phone verification code!"),
},
]}
>
<SendCodeInput
disabled={!this.state.validPhone}
method={"signup"}
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(application)]}
application={application}
countryCode={this.form.current?.getFieldValue("countryCode")}
/>
</Form.Item>
}
</React.Fragment>
);
} else if (signupItem.name === "Password") {

View File

@ -186,6 +186,11 @@ class SignupTable extends React.Component {
{id: "Normal", name: i18next.t("application:Normal")},
{id: "No verification", name: i18next.t("application:No verification")},
];
} else if (record.name === "Phone") {
options = [
{id: "Normal", name: i18next.t("application:Normal")},
{id: "No verification", name: i18next.t("application:No verification")},
];
} else if (record.name === "Agreement") {
options = [
{id: "None", name: i18next.t("application:Only signup")},