feat(cli): notify external hooks about user profile and password changes (#3919)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-08-24 13:47:26 +02:00 committed by GitHub
parent 2d6eea82d3
commit 7d74ddab29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,7 @@ export function meNamespace(this: N8nApp): void {
throw new ResponseHelper.ResponseError('Invalid email address', undefined, 400);
}
const { email: currentEmail } = req.user;
const newUser = new User();
Object.assign(newUser, req.user, req.body);
@ -65,6 +66,7 @@ export function meNamespace(this: N8nApp): void {
user_id: req.user.id,
fields_changed: updatedkeys,
});
await this.externalHooks.run('user.profile.update', [ currentEmail, req.body ]);
return sanitizeUser(user);
},
@ -110,6 +112,8 @@ export function meNamespace(this: N8nApp): void {
fields_changed: ['password'],
});
await this.externalHooks.run('user.password.update', [ user.email, req.user.password ]);
return { success: true };
}),
);