Merge dev - test #1881
|
@ -40,17 +40,10 @@ module.exports = Self => {
|
|||
const userId = ctx.req.accessToken.userId;
|
||||
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
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 userToUpdate = await Self.findById(id, {
|
||||
|
@ -84,12 +77,7 @@ module.exports = Self => {
|
|||
userToUpdate.roleFk = roleFk;
|
||||
}
|
||||
|
||||
await userToUpdate.save(myOptions);
|
||||
await models.Account.sync(userToUpdate.name, null, null, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
} catch (err) {
|
||||
if (tx) await tx.rollback();
|
||||
throw err;
|
||||
};
|
||||
await userToUpdate.save(userToUpdate);
|
||||
await models.Account.sync(userToUpdate.name);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue