mirror of
https://github.com/casdoor/casdoor.git
synced 2025-08-05 12:28:43 +08:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dffa68cbce | ||
![]() |
fad209a7a3 | ||
![]() |
8b222ce2e3 | ||
![]() |
c5293f428d | ||
![]() |
146aec9ee8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -27,3 +27,6 @@ logs/
|
|||||||
files/
|
files/
|
||||||
lastupdate.tmp
|
lastupdate.tmp
|
||||||
commentsRouter*.go
|
commentsRouter*.go
|
||||||
|
|
||||||
|
# ignore build result
|
||||||
|
casdoor
|
@@ -203,12 +203,6 @@ func (c *ApiController) Signup() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = object.CheckUsername(user.Name)
|
|
||||||
if msg != "" {
|
|
||||||
c.ResponseError(msg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
affected := object.AddUser(user)
|
affected := object.AddUser(user)
|
||||||
if !affected {
|
if !affected {
|
||||||
c.ResponseError(fmt.Sprintf("Failed to create user, user information is invalid: %s", util.StructToJson(user)))
|
c.ResponseError(fmt.Sprintf("Failed to create user, user information is invalid: %s", util.StructToJson(user)))
|
||||||
|
@@ -411,12 +411,6 @@ func (c *ApiController) Login() {
|
|||||||
// sync info from 3rd-party if possible
|
// sync info from 3rd-party if possible
|
||||||
object.SetUserOAuthProperties(organization, user, provider.Type, userInfo)
|
object.SetUserOAuthProperties(organization, user, provider.Type, userInfo)
|
||||||
|
|
||||||
msg := object.CheckUsername(user.Name)
|
|
||||||
if msg != "" {
|
|
||||||
c.ResponseError(msg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
affected := object.AddUser(user)
|
affected := object.AddUser(user)
|
||||||
if !affected {
|
if !affected {
|
||||||
c.ResponseError(fmt.Sprintf("Failed to create user, user information is invalid: %s", util.StructToJson(user)))
|
c.ResponseError(fmt.Sprintf("Failed to create user, user information is invalid: %s", util.StructToJson(user)))
|
||||||
|
@@ -158,12 +158,6 @@ func (c *ApiController) UpdateUser() {
|
|||||||
columns = strings.Split(columnsStr, ",")
|
columns = strings.Split(columnsStr, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := object.CheckUsername(user.Name)
|
|
||||||
if msg != "" {
|
|
||||||
c.ResponseError(msg)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
isGlobalAdmin := c.IsGlobalAdmin()
|
isGlobalAdmin := c.IsGlobalAdmin()
|
||||||
affected := object.UpdateUser(id, &user, columns, isGlobalAdmin)
|
affected := object.UpdateUser(id, &user, columns, isGlobalAdmin)
|
||||||
if affected {
|
if affected {
|
||||||
|
@@ -282,7 +282,7 @@ func getUser(gothUser goth.User, provider string) *UserInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if provider == "steam" {
|
if provider == "steam" {
|
||||||
user.Username = user.DisplayName
|
user.Username = user.Id
|
||||||
user.Email = ""
|
user.Email = ""
|
||||||
}
|
}
|
||||||
return &user
|
return &user
|
||||||
|
@@ -59,6 +59,11 @@ func CheckUserSignup(application *Application, organization *Organization, usern
|
|||||||
if reWhiteSpace.MatchString(username) {
|
if reWhiteSpace.MatchString(username) {
|
||||||
return "username cannot contain white spaces"
|
return "username cannot contain white spaces"
|
||||||
}
|
}
|
||||||
|
msg := CheckUsername(username)
|
||||||
|
if msg != "" {
|
||||||
|
return msg
|
||||||
|
}
|
||||||
|
|
||||||
if HasUserByField(organization.Name, "name", username) {
|
if HasUserByField(organization.Name, "name", username) {
|
||||||
return "username already exists"
|
return "username already exists"
|
||||||
}
|
}
|
||||||
@@ -314,16 +319,16 @@ func CheckAccessPermission(userId string, application *Application) (bool, error
|
|||||||
return allowed, err
|
return allowed, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckUsername(name string) string {
|
func CheckUsername(username string) string {
|
||||||
if name == "" {
|
if username == "" {
|
||||||
return "Empty username."
|
return "Empty username."
|
||||||
} else if len(name) > 39 {
|
} else if len(username) > 39 {
|
||||||
return "Username is too long (maximum is 39 characters)."
|
return "Username is too long (maximum is 39 characters)."
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/58726546/github-username-convention-using-regex
|
// https://stackoverflow.com/questions/58726546/github-username-convention-using-regex
|
||||||
re, _ := regexp.Compile("^[a-zA-Z0-9]+((?:-[a-zA-Z0-9]+)|(?:_[a-zA-Z0-9]+))*$")
|
re, _ := regexp.Compile("^[a-zA-Z0-9]+((?:-[a-zA-Z0-9]+)|(?:_[a-zA-Z0-9]+))*$")
|
||||||
if !re.MatchString(name) {
|
if !re.MatchString(username) {
|
||||||
return "The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline."
|
return "The username may only contain alphanumeric characters, underlines or hyphens, cannot have consecutive hyphens or underlines, and cannot begin or end with a hyphen or underline."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -156,8 +156,8 @@ class LoginPage extends React.Component {
|
|||||||
values["type"] = "saml";
|
values["type"] = "saml";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.owner !== null && this.state.owner !== undefined) {
|
if (this.state.application.organization !== null && this.state.application.organization !== undefined) {
|
||||||
values["organization"] = this.state.owner;
|
values["organization"] = this.state.application.organization;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
postCodeLoginAction(res) {
|
postCodeLoginAction(res) {
|
||||||
|
Reference in New Issue
Block a user