Fixed user email case
MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -230,7 +230,7 @@ export default class UserStorage {
issuer: Utils.convertToBoolean(userToSave.issuer),
name: userToSave.name,
firstName: userToSave.firstName,
- email: userToSave.email,
+ email: userToSave.email.toLowerCase(),
phone: userToSave.phone,
mobile: userToSave.mobile,
locale: userToSave.locale,
@@ -602,7 +602,7 @@ export default class UserStorage {
}
// Email
if (params.email) {
- filters.email = params.email;
+ filters.email = { $regex: `^${params.email}$`, $options: 'i' };
}
// Password Reset Hash
if (params.passwordResetHash) {

MODIFY
test/api/AuthenticationTest.ts
test/api/AuthenticationTest.ts
@@ -81,7 +81,7 @@ describe('Authentication Service (utall)', function() {
expect(response.status).to.be.eql(StatusCodes.OK);
expect(response.data).to.have.property('count', 1);
expect(response.data.result).to.have.lengthOf(1);
- expect(user).to.have.property('email', newUser.email);
+ expect(user).to.have.property('email', newUser.email.toLowerCase());
expect(user).to.have.property('name', newUser.name);
expect(user).to.have.property('firstName', newUser.firstName);
expect(user).to.have.property('status', 'P');
@@ -131,7 +131,7 @@ describe('Authentication Service (utall)', function() {
expect(response.data).to.have.property('count', 1);
const user = response.data.result[0];
testData.createdUsersDefaultTenant.push(user);
- expect(user).to.have.property('email', newUser.email);
+ expect(user).to.have.property('email', newUser.email.toLowerCase());
expect(user).to.have.property('name', newUser.name);
expect(user).to.have.property('firstName', newUser.firstName);
expect(user).to.have.property('status', 'P');

Fixed user email case