refs #6023 Fix change rol bug
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
1ad9a30848
commit
d1df8009a6
|
@ -40,10 +40,17 @@ 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, {
|
||||||
|
@ -77,7 +84,12 @@ module.exports = Self => {
|
||||||
userToUpdate.roleFk = roleFk;
|
userToUpdate.roleFk = roleFk;
|
||||||
}
|
}
|
||||||
|
|
||||||
await userToUpdate.save(userToUpdate);
|
await userToUpdate.save(myOptions);
|
||||||
await models.Account.sync(userToUpdate.name);
|
await models.Account.sync(userToUpdate.name, null, null, myOptions);
|
||||||
|
await tx.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw err;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,11 @@ module.exports = Self => {
|
||||||
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;
|
||||||
|
};
|
||||||
|
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const user = await models.VnUser.findOne({
|
const user = await models.VnUser.findOne({
|
||||||
fields: ['id'],
|
fields: ['id'],
|
||||||
|
|
Loading…
Reference in New Issue