mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 04:10:20 +08:00
Improve password length check.
This commit is contained in:
@ -70,6 +70,11 @@ func (c *ApiController) UpdateUser() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if user.DisplayName == "" {
|
||||||
|
c.ResponseError("Display name cannot be empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
c.Data["json"] = wrapActionResponse(object.UpdateUser(id, &user))
|
c.Data["json"] = wrapActionResponse(object.UpdateUser(id, &user))
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
@ -160,12 +165,12 @@ func (c *ApiController) SetPassword() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.Index(newPassword, " ") >= 0 {
|
if strings.Index(newPassword, " ") >= 0 {
|
||||||
c.ResponseError("New password contains blank space.")
|
c.ResponseError("New password cannot contain blank space.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if newPassword == "" {
|
if len(newPassword) <= 5 {
|
||||||
c.ResponseError("Invalid new password")
|
c.ResponseError("New password must have at least 6 characters")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ func init() {
|
|||||||
func CheckUserSignup(organizationName string, username string, password string, displayName string, email string, phone string, affiliation string) string {
|
func CheckUserSignup(organizationName string, username string, password string, displayName string, email string, phone string, affiliation string) string {
|
||||||
organization := getOrganization("admin", organizationName)
|
organization := getOrganization("admin", organizationName)
|
||||||
|
|
||||||
if len(username) == 0 {
|
if len(username) <= 2 {
|
||||||
return "username cannot be blank"
|
return "username must have at least 3 characters"
|
||||||
} else if len(password) == 0 {
|
} else if len(password) <= 5 {
|
||||||
return "password cannot be blank"
|
return "password must have at least 6 characters"
|
||||||
} else if organization == nil {
|
} else if organization == nil {
|
||||||
return "organization does not exist"
|
return "organization does not exist"
|
||||||
} else if reWhiteSpace.MatchString(username) {
|
} else if reWhiteSpace.MatchString(username) {
|
||||||
|
@ -173,7 +173,7 @@ class UserEditPage extends React.Component {
|
|||||||
{i18next.t("general:Organization")}:
|
{i18next.t("general:Organization")}:
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<Select virtual={false} style={{width: '100%'}} value={this.state.user.owner} onChange={(value => {this.updateUserField('owner', value);})}>
|
<Select virtual={false} style={{width: '100%'}} disabled={!Setting.isAdminUser(this.props.account)} value={this.state.user.owner} onChange={(value => {this.updateUserField('owner', value);})}>
|
||||||
{
|
{
|
||||||
this.state.organizations.map((organization, index) => <Option key={index} value={organization.name}>{organization.name}</Option>)
|
this.state.organizations.map((organization, index) => <Option key={index} value={organization.name}>{organization.name}</Option>)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user