Squash username to lowercase at login

Signed-off-by: Bernard Zhao <bernard.zhao.us@gmail.com>
This commit is contained in:
Bernard Zhao 2021-11-30 23:07:11 -08:00
parent 83b9cb4d79
commit 71d70c106d
No known key found for this signature in database
GPG key ID: A16C417E8F9C993B

View file

@ -17,6 +17,7 @@ package auth
import (
"context"
"net/http"
"strings"
"github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/clientapi/userutil"
@ -48,7 +49,8 @@ func (t *LoginTypePassword) Request() interface{} {
func (t *LoginTypePassword) Login(ctx context.Context, req interface{}) (*Login, *util.JSONResponse) {
r := req.(*PasswordRequest)
username := r.Username()
// Squash username to all lowercase letters
username := strings.ToLower(r.Username())
if username == "" {
return nil, &util.JSONResponse{
Code: http.StatusUnauthorized,