Skip to content

Commit

Permalink
feat: password and invitation code verification rules (casdoor#2258)
Browse files Browse the repository at this point in the history
  • Loading branch information
leo220yuyaodog authored Aug 25, 2023
1 parent 9da2f07 commit 7970ede
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 0 additions & 7 deletions controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ func (c *ApiController) Signup() {
username = id
}

password := authForm.Password
msg = object.CheckPasswordComplexityByOrg(organization, password)
if msg != "" {
c.ResponseError(msg)
return
}

initScore, err := organization.GetInitScore()
if err != nil {
c.ResponseError(fmt.Errorf(c.T("account:Get init score failed, error: %w"), err).Error())
Expand Down
11 changes: 8 additions & 3 deletions object/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ func CheckUserSignup(application *Application, organization *Organization, form
}
}

if len(form.Password) <= 5 {
return i18n.Translate(lang, "check:Password must have at least 6 characters")
if application.IsSignupItemVisible("Password") {
msg := CheckPasswordComplexityByOrg(organization, form.Password)
if msg != "" {
return msg
}
}

if application.IsSignupItemVisible("Email") {
Expand Down Expand Up @@ -126,7 +129,9 @@ func CheckUserSignup(application *Application, organization *Organization, form

if len(application.InvitationCodes) > 0 {
if form.InvitationCode == "" {
return i18n.Translate(lang, "check:Invitation code cannot be blank")
if application.IsSignupItemRequired("Invitation code") {
return i18n.Translate(lang, "check:Invitation code cannot be blank")
}
} else {
if !util.InSlice(application.InvitationCodes, form.InvitationCode) {
return i18n.Translate(lang, "check:Invitation code is invalid")
Expand Down
2 changes: 1 addition & 1 deletion web/src/table/SignupTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class SignupTable extends React.Component {
}

return (
<Switch checked={text} onChange={checked => {
<Switch checked={text} disabled={record.name === "Password"} onChange={checked => {
this.updateField(table, index, "required", checked);
}} />
);
Expand Down

0 comments on commit 7970ede

Please sign in to comment.