From d12ee1dd790733a3e725323d2090116eac88d352 Mon Sep 17 00:00:00 2001 From: Dovile Date: Fri, 13 Oct 2023 09:35:00 +0300 Subject: [PATCH] fix tenants auth emails --- services/tenants.service.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/tenants.service.ts b/services/tenants.service.ts index 3566a17..89404e0 100644 --- a/services/tenants.service.ts +++ b/services/tenants.service.ts @@ -157,8 +157,16 @@ export default class TenantsService extends moleculer.Service { personalCode, } = ctx.params; - // it will throw error if tenant aleady exists - const authGroup: any = await ctx.call('auth.users.invite', { companyCode }); + const inviteData: any = { + companyCode: ctx.params.companyCode, + throwErrors: true, + }; + if (ctx.params.companyEmail) { + inviteData.notify = [ctx.params.companyEmail]; + } + + // it will throw error if tenant already exists + const authGroup: any = await ctx.call('auth.users.invite', inviteData); const tenant: Tenant = await this.createEntity(ctx, { authGroup: authGroup.id,