Skip to content

Commit

Permalink
feat: Allow to sign up with Email without verification (casdoor#728)
Browse files Browse the repository at this point in the history
* feat: Allow to sign up with Email without verification by rule

* Update account.go

* Update SignupTable.js

* Update SignupPage.js

Co-authored-by: Yang Luo <[email protected]>
  • Loading branch information
Resulte and hsluoyz authored May 2, 2022
1 parent 4acba2d commit c4089ea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (c *ApiController) Signup() {
return
}

if application.IsSignupItemVisible("Email") && form.Email != "" {
if application.IsSignupItemVisible("Email") && application.GetSignupItemRule("Email") != "No verification" && form.Email != "" {
checkResult := object.CheckVerificationCode(form.Email, form.EmailCode)
if len(checkResult) != 0 {
c.ResponseError(fmt.Sprintf("Email: %s", checkResult))
Expand Down
2 changes: 1 addition & 1 deletion object/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func initBuiltInApplication() {
{Name: "Display name", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Password", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Confirm password", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Email", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Email", Visible: true, Required: true, Prompted: false, Rule: "Normal"},
{Name: "Phone", Visible: true, Required: true, Prompted: false, Rule: "None"},
{Name: "Agreement", Visible: true, Required: true, Prompted: false, Rule: "None"},
},
Expand Down
2 changes: 1 addition & 1 deletion web/src/ApplicationListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ApplicationListPage extends BaseListPage {
{name: "Display name", visible: true, required: true, rule: "None"},
{name: "Password", visible: true, required: true, rule: "None"},
{name: "Confirm password", visible: true, required: true, rule: "None"},
{name: "Email", visible: true, required: true, rule: "None"},
{name: "Email", visible: true, required: true, rule: "Normal"},
{name: "Phone", visible: true, required: true, rule: "None"},
{name: "Agreement", visible: true, required: true, rule: "None"},
],
Expand Down
9 changes: 7 additions & 2 deletions web/src/SignupTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,25 @@ class SignupTable extends React.Component {
title: i18next.t("provider:rule"),
dataIndex: 'rule',
key: 'rule',
width: '120px',
width: '155px',
render: (text, record, index) => {
let options = [];
if (record.name === "ID") {
options = [
{id: 'Random', name: 'Random'},
{id: 'Incremental', name: 'Incremental'},
];
} if (record.name === "Display name") {
} else if (record.name === "Display name") {
options = [
{id: 'None', name: 'None'},
{id: 'Real name', name: 'Real name'},
{id: 'First, last', name: 'First, last'},
];
} else if (record.name === "Email") {
options = [
{id: 'Normal', name: 'Normal'},
{id: 'No Verification', name: 'No verification'},
];
}

if (options.length === 0) {
Expand Down
31 changes: 17 additions & 14 deletions web/src/auth/SignupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,23 @@ class SignupPage extends React.Component {
>
<Input onChange={e => this.setState({email: e.target.value})} />
</Form.Item>
<Form.Item
name="emailCode"
key="emailCode"
label={i18next.t("code:Email code")}
rules={[{
required: required,
message: i18next.t("code:Please input your verification code!"),
}]}
>
<CountDownInput
disabled={!this.state.validEmail}
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationOrgName(application)]}
/>
</Form.Item>
{
signupItem.rule !== "No verification" &&
<Form.Item
name="emailCode"
key="emailCode"
label={i18next.t("code:Email code")}
rules={[{
required: required,
message: i18next.t("code:Please input your verification code!"),
}]}
>
<CountDownInput
disabled={!this.state.validEmail}
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationOrgName(application)]}
/>
</Form.Item>
}
</React.Fragment>
)
} else if (signupItem.name === "Phone") {
Expand Down

0 comments on commit c4089ea

Please sign in to comment.