Skip to content

Commit fccad9f

Browse files
committed
fix(api): fix findAnotherUserByEmail case insensitive user account search
1 parent 93de2e6 commit fccad9f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

api/src/identity-access-management/infrastructure/repositories/user.repository.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ const findByExternalIdentifier = async function ({ externalIdentityId, identityP
390390
};
391391

392392
const findAnotherUserByEmail = async function (userId, email) {
393-
const anotherUsers = await knex('users').whereNot('id', userId).where({ email: email.toLowerCase() });
393+
const anotherUsers = await knex('users').whereNot('id', userId).whereRaw('LOWER("email") = ?', email.toLowerCase());
394394

395395
return anotherUsers.map((anotherUser) => new User(anotherUser));
396396
};

api/tests/identity-access-management/integration/infrastructure/repositories/user.repository.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ describe('Integration | Identity Access Management | Infrastructure | Repository
601601
602602
});
603603
const anotherUser = databaseBuilder.factory.buildUser({
604-
604+
email: 'another.user.withSomeUpperCaseLetters@example.net',
605605
});
606606
await databaseBuilder.commit();
607607

@@ -611,7 +611,7 @@ describe('Integration | Identity Access Management | Infrastructure | Repository
611611
// then
612612
expect(foundUsers).to.be.an('array').that.have.lengthOf(1);
613613
expect(foundUsers[0]).to.be.an.instanceof(User);
614-
expect(foundUsers[0].email).to.equal(anotherUser.email);
614+
expect(foundUsers[0].email).to.equal(anotherUser.email.toLowerCase());
615615
});
616616

617617
it('returns an empty list if email is not used', async function () {

0 commit comments

Comments
 (0)