mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-26 13:41:33 +00:00
Squash username to all lowercase letters upon registration (#361)
* Squash username to all lowercase letters upon registration Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
This commit is contained in:
parent
cc12fc930a
commit
791a5ee7f4
@ -49,7 +49,7 @@ const (
|
||||
var (
|
||||
// TODO: Remove old sessions. Need to do so on a session-specific timeout.
|
||||
sessions = make(map[string][]authtypes.LoginType) // Sessions and completed flow stages
|
||||
validUsernameRegex = regexp.MustCompile(`^[0-9a-zA-Z_\-./]+$`)
|
||||
validUsernameRegex = regexp.MustCompile(`^[0-9a-z_\-./]+$`)
|
||||
)
|
||||
|
||||
// registerRequest represents the submitted registration request.
|
||||
@ -183,6 +183,9 @@ func Register(
|
||||
}
|
||||
}
|
||||
|
||||
// Squash username to all lowercase letters
|
||||
r.Username = strings.ToLower(r.Username)
|
||||
|
||||
if resErr = validateUserName(r.Username); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
@ -278,6 +281,10 @@ func LegacyRegister(
|
||||
if resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
|
||||
// Squash username to all lowercase letters
|
||||
r.Username = strings.ToLower(r.Username)
|
||||
|
||||
if resErr = validateUserName(r.Username); resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
@ -478,6 +485,9 @@ func RegisterAvailable(
|
||||
) util.JSONResponse {
|
||||
username := req.URL.Query().Get("username")
|
||||
|
||||
// Squash username to all lowercase letters
|
||||
username = strings.ToLower(username)
|
||||
|
||||
if err := validateUserName(username); err != nil {
|
||||
return *err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user