create hook in account
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2020-06-08 12:18:33 +02:00
parent 79b143478e
commit 2a53d4bca5
1 changed files with 2 additions and 6 deletions

View File

@ -12,15 +12,13 @@ module.exports = Self => {
message: `A client with that Web User name already exists`
});
Self.observe('before save', async function(ctx, next) {
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.data && (ctx.data.name || ctx.data.active)) {
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;
console.log('ctx.data', ctx.data);
console.log('ctx.currentInstance', ctx.currentInstance);
let logRecord = {
originFk: ctx.currentInstance.id,
userFk: userId,
@ -31,8 +29,6 @@ module.exports = Self => {
};
await Self.app.models.ClientLog.create(logRecord);
}
next();
});
Self.remoteMethod('getCurrentUserData', {