Skip to content

Commit

Permalink
fix tenants auth emails
Browse files Browse the repository at this point in the history
  • Loading branch information
DovMa committed Oct 13, 2023
1 parent f698f18 commit d12ee1d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions services/tenants.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d12ee1d

Please sign in to comment.