mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 07:32:56 +08:00
feat: allow non-ASCII characters in username (#1235)
This commit is contained in:
@@ -326,6 +326,11 @@ func CheckUsername(username string) string {
|
|||||||
return "Username is too long (maximum is 39 characters)."
|
return "Username is too long (maximum is 39 characters)."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exclude, _ := regexp.Compile("^[\u0021-\u007E]+$")
|
||||||
|
if !exclude.MatchString(username) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// 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(username) {
|
if !re.MatchString(username) {
|
||||||
|
Reference in New Issue
Block a user