mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 05:10:19 +08:00
fix: Add support for including underscores for username (#1210)
* fix: Add support for including underscores for username * Update check.go Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
@ -322,11 +322,9 @@ func CheckUsername(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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]+)*$")
|
re, _ := regexp.Compile("^[a-zA-Z0-9]+((?:-[a-zA-Z0-9]+)|(?:_[a-zA-Z0-9]+))*$")
|
||||||
if !re.MatchString(name) {
|
if !re.MatchString(name) {
|
||||||
return fmt.Sprintf("The name '%s' may only contain alphanumeric characters or hyphens, "+
|
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."
|
||||||
"cannot have multiple consecutive hyphens, "+
|
|
||||||
"and cannot begin or end with a hyphen.", name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
Reference in New Issue
Block a user