historically, usernames can start with a number. Let them login.
This commit is contained in:
parent
d728e01149
commit
889535574d
|
@ -35,7 +35,7 @@ final class DataForm(
|
||||||
Constraints minLength 2,
|
Constraints minLength 2,
|
||||||
Constraints maxLength 20,
|
Constraints maxLength 20,
|
||||||
Constraints.pattern(
|
Constraints.pattern(
|
||||||
regex = User.usernameRegex,
|
regex = User.newUsernameRegex,
|
||||||
error = "usernameInvalid"
|
error = "usernameInvalid"
|
||||||
)
|
)
|
||||||
).verifying("usernameUnacceptable", u => !LameName.username(u))
|
).verifying("usernameUnacceptable", u => !LameName.username(u))
|
||||||
|
|
|
@ -140,8 +140,12 @@ object User {
|
||||||
// No: contact@lichess.org, @1, http://example.com/@happy0
|
// No: contact@lichess.org, @1, http://example.com/@happy0
|
||||||
val atUsernameRegex = """(?<=\s|^)@(?>([a-zA-Z_-][\w-]{1,19}))(?![\w-])""".r
|
val atUsernameRegex = """(?<=\s|^)@(?>([a-zA-Z_-][\w-]{1,19}))(?![\w-])""".r
|
||||||
|
|
||||||
val usernameRegex = """(?i)[a-z][\w-]*[a-z0-9]""".r
|
// what existing usernames are like
|
||||||
def couldBeUsername(str: String) = usernameRegex.pattern.matcher(str).matches
|
val historicalUsernameRegex = """(?i)[\w-]*[a-z0-9]""".r
|
||||||
|
// what new usernames should be like
|
||||||
|
val newUsernameRegex = """(?i)[a-z][\w-]*[a-z0-9]""".r
|
||||||
|
|
||||||
|
def couldBeUsername(str: String) = historicalUsernameRegex.pattern.matcher(str).matches
|
||||||
|
|
||||||
def normalize(username: String) = username.toLowerCase
|
def normalize(username: String) = username.toLowerCase
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue