Users: Enable case insensitive login by default (#66134)
* enable case insensitive by default * fix missing case-insensitive query * fix missing case insensitive query * fix missing case insensitive query in temp_user * skip integration testing in mysql * skip integration testing in mysql * use t.cleanup * lowercase only once * aligned to only using sql as that is what we do in other parts --------- Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
This commit is contained in:
@@ -88,8 +88,16 @@ func (ss *sqlStore) Insert(ctx context.Context, cmd *user.User) (int64, error) {
|
||||
}
|
||||
|
||||
func (ss *sqlStore) Get(ctx context.Context, usr *user.User) (*user.User, error) {
|
||||
ret := &user.User{}
|
||||
err := ss.db.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
exists, err := sess.Where("email=? OR login=?", usr.Email, usr.Login).Get(usr)
|
||||
where := "email=? OR login=?"
|
||||
login := usr.Login
|
||||
email := usr.Email
|
||||
if ss.cfg.CaseInsensitiveLogin {
|
||||
where = "LOWER(email)=LOWER(?) OR LOWER(login)=LOWER(?)"
|
||||
}
|
||||
|
||||
exists, err := sess.Where(where, email, login).Get(ret)
|
||||
if !exists {
|
||||
return user.ErrUserNotFound
|
||||
}
|
||||
@@ -101,7 +109,8 @@ func (ss *sqlStore) Get(ctx context.Context, usr *user.User) (*user.User, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return usr, nil
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (ss *sqlStore) Delete(ctx context.Context, userID int64) error {
|
||||
|
||||
Reference in New Issue
Block a user