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 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) checkPhone, _ = util.GetE164Number(form.Phone, form.CountryCode)
checkResult := object.CheckVerificationCode(checkPhone, form.PhoneCode, c.GetAcceptLanguage()) checkResult := object.CheckVerificationCode(checkPhone, form.PhoneCode, c.GetAcceptLanguage())
if checkResult.Code != object.VerificationSuccess { if checkResult.Code != object.VerificationSuccess {

View File

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

View File

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

View File

@ -186,6 +186,11 @@ class SignupTable extends React.Component {
{id: "Normal", name: i18next.t("application:Normal")}, {id: "Normal", name: i18next.t("application:Normal")},
{id: "No verification", name: i18next.t("application:No verification")}, {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") { } else if (record.name === "Agreement") {
options = [ options = [
{id: "None", name: i18next.t("application:Only signup")}, {id: "None", name: i18next.t("application:Only signup")},