feat: password and invitation code verification rules (#2258)

This commit is contained in:
Yaodong Yu 2023-08-25 21:16:21 +08:00 committed by GitHub
parent 9da2f0775f
commit 7970edeaa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -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())

View File

@ -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") {
@ -126,7 +129,9 @@ func CheckUserSignup(application *Application, organization *Organization, form
if len(application.InvitationCodes) > 0 {
if form.InvitationCode == "" {
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")

View File

@ -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);
}} />
);