first step, client hook
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0a2366194a
commit
ee58aebe16
|
@ -15,20 +15,6 @@ module.exports = Self => {
|
|||
Self.observe('before save', async function(ctx) {
|
||||
if (ctx.currentInstance && ctx.currentInstance.id && ctx.data && ctx.data.password)
|
||||
ctx.data.password = md5(ctx.data.password);
|
||||
|
||||
if (!ctx.isNewInstance && ctx.data && (ctx.data.name || ctx.data.active)) {
|
||||
let instance = JSON.parse(JSON.stringify(ctx.currentInstance));
|
||||
let userId = ctx.options.accessToken.userId;
|
||||
let logRecord = {
|
||||
originFk: ctx.currentInstance.id,
|
||||
userFk: userId,
|
||||
action: 'update',
|
||||
changedModel: 'Account',
|
||||
oldInstance: {name: instance.name, active: instance.active},
|
||||
newInstance: ctx.data
|
||||
};
|
||||
await Self.app.models.ClientLog.create(logRecord);
|
||||
}
|
||||
});
|
||||
|
||||
Self.remoteMethod('getCurrentUserData', {
|
||||
|
|
|
@ -218,6 +218,27 @@ module.exports = Self => {
|
|||
await Self.app.models.ClientCredit.create(newCredit);
|
||||
}
|
||||
});
|
||||
// const app = require('vn-loopback/server/server');
|
||||
// Self.observe('loaded', async ctx => {
|
||||
// let account = Self.app.models.Account;
|
||||
// account.observe('after save', async ctx => {
|
||||
// console.log('ctx.isNewInstance', ctx.isNewInstance);
|
||||
// if (!ctx.isNewInstance && ctx.data && (ctx.data.name || ctx.data.active)) {
|
||||
// console.log('ctx.isNewInstance', ctx.isNewInstance);
|
||||
// let instance = JSON.parse(JSON.stringify(ctx.currentInstance));
|
||||
// let userId = ctx.options.accessToken.userId;
|
||||
// let logRecord = {
|
||||
// originFk: ctx.currentInstance.id,
|
||||
// userFk: userId,
|
||||
// action: 'update',
|
||||
// changedModel: 'Account',
|
||||
// oldInstance: {name: instance.name, active: instance.active},
|
||||
// newInstance: ctx.data
|
||||
// };
|
||||
// await Self.app.models.ClientLog.create(logRecord);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
Self.observe('after save', async ctx => {
|
||||
if (ctx.isNewInstance) return;
|
||||
|
|
Loading…
Reference in New Issue