Merge dev - test #1881

Merged
jsegarra merged 71 commits from dev into test 2023-12-07 08:28:25 +00:00
1 changed files with 27 additions and 39 deletions
Showing only changes of commit 9f92bc4b4c - Show all commits

View File

@ -40,17 +40,10 @@ module.exports = Self => {
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const myOptions = {}; const myOptions = {};
let tx;
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
};
try {
const user = await Self.findById(userId, {fields: ['hasGrant']}, myOptions); const user = await Self.findById(userId, {fields: ['hasGrant']}, myOptions);
const userToUpdate = await Self.findById(id, { const userToUpdate = await Self.findById(id, {
@ -84,12 +77,7 @@ module.exports = Self => {
userToUpdate.roleFk = roleFk; userToUpdate.roleFk = roleFk;
} }
await userToUpdate.save(myOptions); await userToUpdate.save(userToUpdate);
await models.Account.sync(userToUpdate.name, null, null, myOptions); await models.Account.sync(userToUpdate.name);
if (tx) await tx.commit();
} catch (err) {
if (tx) await tx.rollback();
throw err;
};
}; };
}; };