better transaction handling with rollback on exception

This commit is contained in:
azivner
2017-10-29 18:50:28 -04:00
parent afadd6ec06
commit de3d1b3e39
8 changed files with 145 additions and 150 deletions

View File

@@ -55,15 +55,13 @@ async function changePassword(currentPassword, newPassword, req = null) {
const newEncryptedDataKey = encrypt(decryptedDataKey);
await sql.beginTransaction();
await sql.doInTransaction(async () => {
await sql.setOption('encrypted_data_key', newEncryptedDataKey);
await sql.setOption('encrypted_data_key', newEncryptedDataKey);
await sql.setOption('password_verification_hash', newPasswordVerificationKey);
await sql.setOption('password_verification_hash', newPasswordVerificationKey);
await sql.addAudit(audit_category.CHANGE_PASSWORD, req);
await sql.commit();
await sql.addAudit(audit_category.CHANGE_PASSWORD, req);
});
return {
'success': true,