diff --git a/app/lib/server/methods/deleteUserOwnAccount.js b/app/lib/server/methods/deleteUserOwnAccount.js index 62c27450c3a8..0b5670abd25c 100644 --- a/app/lib/server/methods/deleteUserOwnAccount.js +++ b/app/lib/server/methods/deleteUserOwnAccount.js @@ -27,7 +27,10 @@ Meteor.methods({ } if (user.services && user.services.password && s.trim(user.services.password.bcrypt)) { - const result = Accounts._checkPassword(user, { digest: password, algorithm: 'sha-256' }); + const result = Accounts._checkPassword(user, { + digest: password.toLowerCase(), + algorithm: 'sha-256', + }); if (result.error) { throw new Meteor.Error('error-invalid-password', 'Invalid password', { method: 'deleteUserOwnAccount' }); } diff --git a/server/methods/saveUserProfile.js b/server/methods/saveUserProfile.js index 2fdf5e5fafdb..037bc83eead7 100644 --- a/server/methods/saveUserProfile.js +++ b/server/methods/saveUserProfile.js @@ -31,7 +31,7 @@ Meteor.methods({ } const passCheck = Accounts._checkPassword(user, { - digest: typedPassword, + digest: typedPassword.toLowerCase(), algorithm: 'sha-256', }); diff --git a/tests/end-to-end/api/01-users.js b/tests/end-to-end/api/01-users.js index 5b11589e7748..5470a1210271 100644 --- a/tests/end-to-end/api/01-users.js +++ b/tests/end-to-end/api/01-users.js @@ -14,6 +14,7 @@ import { adminEmail, preferences, password, adminUsername } from '../../data/use import { imgURL } from '../../data/interactions.js'; import { customFieldText, clearCustomFields, setCustomFields } from '../../data/custom-fields.js'; import { updatePermission, updateSetting } from '../../data/permissions.helper'; +import { createUser, login } from '../../data/users.helper.js'; describe('[Users]', function() { this.retries(0); @@ -1326,6 +1327,24 @@ describe('[Users]', function() { }) .end(done); }); + + it('should delete user own account when the SHA256 hash is in upper case', (done) => { + createUser().then((user) => { + login(user.username, password).then((createdUserCredentials) => { + request.post(api('users.deleteOwnAccount')) + .set(createdUserCredentials) + .send({ + password: crypto.createHash('sha256').update(password, 'utf8').digest('hex').toUpperCase(), + }) + .expect('Content-Type', 'application/json') + .expect(200) + .expect((res) => { + expect(res.body).to.have.property('success', true); + }) + .end(done); + }); + }); + }); }); describe('[/users.delete]', () => {