feat(cli): add external hooks for when members are added or deleted (#3988)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-09-05 09:03:05 +02:00 committed by GitHub
parent fc6484ba4d
commit 6be999714f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View file

@ -66,7 +66,7 @@ export function meNamespace(this: N8nApp): void {
user_id: req.user.id, user_id: req.user.id,
fields_changed: updatedkeys, fields_changed: updatedkeys,
}); });
await this.externalHooks.run('user.profile.update', [currentEmail, req.body]); await this.externalHooks.run('user.profile.update', [currentEmail, sanitizeUser(user)]);
return sanitizeUser(user); return sanitizeUser(user);
}, },

View file

@ -214,6 +214,8 @@ export function usersNamespace(this: N8nApp): void {
}), }),
); );
await this.externalHooks.run('user.invited', [usersToSetUp]);
Logger.debug( Logger.debug(
usersPendingSetup.length > 1 usersPendingSetup.length > 1
? `Sent ${usersPendingSetup.length} invite emails successfully` ? `Sent ${usersPendingSetup.length} invite emails successfully`
@ -363,6 +365,9 @@ export function usersNamespace(this: N8nApp): void {
user_id: invitee.id, user_id: invitee.id,
}); });
await this.externalHooks.run('user.profile.update', [invitee.email, sanitizeUser(invitee)]);
await this.externalHooks.run('user.password.update', [invitee.email, invitee.password]);
return sanitizeUser(updatedUser); return sanitizeUser(updatedUser);
}), }),
); );
@ -478,6 +483,8 @@ export function usersNamespace(this: N8nApp): void {
void InternalHooksManager.getInstance().onUserDeletion(req.user.id, telemetryData, false); void InternalHooksManager.getInstance().onUserDeletion(req.user.id, telemetryData, false);
await this.externalHooks.run('user.deleted', [sanitizeUser(userToDelete)]);
return { success: true }; return { success: true };
}), }),
); );

View file

@ -98,7 +98,11 @@ export async function initTestServer({
if (!endpointGroups) return testServer.app; if (!endpointGroups) return testServer.app;
if (endpointGroups.includes('credentials') || endpointGroups.includes('me')) { if (
endpointGroups.includes('credentials') ||
endpointGroups.includes('me') ||
endpointGroups.includes('users')
) {
testServer.externalHooks = ExternalHooks(); testServer.externalHooks = ExternalHooks();
} }