From 12507d39d68a2961c6e567b6b7d83759010918b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 9 Sep 2022 14:01:48 +0200 Subject: [PATCH] fix(cli): password reset should trigger internal and external hooks (#4066) Ticket: N8N-4586 --- packages/cli/src/UserManagement/routes/passwordReset.ts | 7 +++++++ packages/cli/test/integration/shared/utils.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/UserManagement/routes/passwordReset.ts b/packages/cli/src/UserManagement/routes/passwordReset.ts index e621ab7b9d..ca22efd7c3 100644 --- a/packages/cli/src/UserManagement/routes/passwordReset.ts +++ b/packages/cli/src/UserManagement/routes/passwordReset.ts @@ -215,6 +215,13 @@ export function passwordResetNamespace(this: N8nApp): void { Logger.info('User password updated successfully', { userId }); await issueCookie(res, user); + + void InternalHooksManager.getInstance().onUserUpdate({ + user_id: userId, + fields_changed: ['password'], + }); + + await this.externalHooks.run('user.password.update', [user.email, password]); }), ); } diff --git a/packages/cli/test/integration/shared/utils.ts b/packages/cli/test/integration/shared/utils.ts index b3faaf8b0b..5fa3890fe2 100644 --- a/packages/cli/test/integration/shared/utils.ts +++ b/packages/cli/test/integration/shared/utils.ts @@ -101,7 +101,8 @@ export async function initTestServer({ if ( endpointGroups.includes('credentials') || endpointGroups.includes('me') || - endpointGroups.includes('users') + endpointGroups.includes('users') || + endpointGroups.includes('passwordReset') ) { testServer.externalHooks = ExternalHooks(); }