mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Fix #2287 by trying to fetch account by lowercase localpart and as
passed by request
This commit is contained in:
parent
9572f5ed19
commit
5ce7f13bba
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
|
@ -298,7 +299,20 @@ func (d *Database) CheckAccountAvailability(ctx context.Context, localpart strin
|
||||||
// Returns sql.ErrNoRows if no account exists which matches the given localpart.
|
// Returns sql.ErrNoRows if no account exists which matches the given localpart.
|
||||||
func (d *Database) GetAccountByLocalpart(ctx context.Context, localpart string,
|
func (d *Database) GetAccountByLocalpart(ctx context.Context, localpart string,
|
||||||
) (*api.Account, error) {
|
) (*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))
|
||||||
|
switch err {
|
||||||
|
case sql.ErrNoRows: // try with localpart as passed by the request
|
||||||
|
acc, err = d.Accounts.SelectAccountByLocalpart(ctx, localpart)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return acc, nil
|
||||||
|
case nil:
|
||||||
|
return acc, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchProfiles returns all profiles where the provided localpart or display name
|
// SearchProfiles returns all profiles where the provided localpart or display name
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue