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>main
parent
cc12fc930a
commit
791a5ee7f4
|
@ -49,7 +49,7 @@ const (
|
||||||
var (
|
var (
|
||||||
// TODO: Remove old sessions. Need to do so on a session-specific timeout.
|
// TODO: Remove old sessions. Need to do so on a session-specific timeout.
|
||||||
sessions = make(map[string][]authtypes.LoginType) // Sessions and completed flow stages
|
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.
|
// 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 {
|
if resErr = validateUserName(r.Username); resErr != nil {
|
||||||
return *resErr
|
return *resErr
|
||||||
}
|
}
|
||||||
|
@ -278,6 +281,10 @@ func LegacyRegister(
|
||||||
if resErr != nil {
|
if resErr != nil {
|
||||||
return *resErr
|
return *resErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Squash username to all lowercase letters
|
||||||
|
r.Username = strings.ToLower(r.Username)
|
||||||
|
|
||||||
if resErr = validateUserName(r.Username); resErr != nil {
|
if resErr = validateUserName(r.Username); resErr != nil {
|
||||||
return *resErr
|
return *resErr
|
||||||
}
|
}
|
||||||
|
@ -478,6 +485,9 @@ func RegisterAvailable(
|
||||||
) util.JSONResponse {
|
) util.JSONResponse {
|
||||||
username := req.URL.Query().Get("username")
|
username := req.URL.Query().Get("username")
|
||||||
|
|
||||||
|
// Squash username to all lowercase letters
|
||||||
|
username = strings.ToLower(username)
|
||||||
|
|
||||||
if err := validateUserName(username); err != nil {
|
if err := validateUserName(username); err != nil {
|
||||||
return *err
|
return *err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue