diff options
author | S7evinK <2353100+S7evinK@users.noreply.github.com> | 2022-03-23 13:55:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 13:55:34 +0100 |
commit | 6e8cca344aa5ea4356d33e1594c725a6e60b5d5e (patch) | |
tree | d5d75541f7d2f42abf7533a388a10a5acbd694f3 | |
parent | 3213910977db46dea7398ddb75d67584a99f57b4 (diff) |
Fix #2287 by trying to fetch account by lowercase localpart (#2292)
* Fix #2287 by trying to fetch account by lowercase localpart and as
passed by request
-rw-r--r-- | userapi/storage/shared/storage.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/userapi/storage/shared/storage.go b/userapi/storage/shared/storage.go index febf0322..72ae96ec 100644 --- a/userapi/storage/shared/storage.go +++ b/userapi/storage/shared/storage.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "strconv" + "strings" "time" "github.com/matrix-org/gomatrixserverlib" @@ -298,7 +299,12 @@ func (d *Database) CheckAccountAvailability(ctx context.Context, localpart strin // Returns sql.ErrNoRows if no account exists which matches the given localpart. func (d *Database) GetAccountByLocalpart(ctx context.Context, localpart string, ) (*api.Account, error) { - return d.Accounts.SelectAccountByLocalpart(ctx, localpart) + // try to get the account with lowercase localpart (majority) + acc, err := d.Accounts.SelectAccountByLocalpart(ctx, strings.ToLower(localpart)) + if err == sql.ErrNoRows { + acc, err = d.Accounts.SelectAccountByLocalpart(ctx, localpart) // try with localpart as passed by the request + } + return acc, err } // SearchProfiles returns all profiles where the provided localpart or display name |