diff --git a/packages/core/e2e/customer.e2e-spec.ts b/packages/core/e2e/customer.e2e-spec.ts index 3f4c1a72d0..df78313bde 100644 --- a/packages/core/e2e/customer.e2e-spec.ts +++ b/packages/core/e2e/customer.e2e-spec.ts @@ -61,7 +61,7 @@ class TestEmailPlugin implements OnModuleInit { onModuleInit() { this.eventBus.ofType(AccountRegistrationEvent).subscribe(event => { - sendEmailFn(event); + sendEmailFn?.(event); }); } } @@ -505,7 +505,7 @@ describe('Customer resolver', () => { customerErrorGuard.assertSuccess(createCustomer); expect(createCustomer.user!.verified).toBe(true); - expect(sendEmailFn).toHaveBeenCalledTimes(0); + expect(sendEmailFn).toHaveBeenCalledTimes(1); }); it('return error result when using an existing, non-deleted emailAddress', async () => { diff --git a/packages/core/e2e/shop-auth.e2e-spec.ts b/packages/core/e2e/shop-auth.e2e-spec.ts index 69e8285ccc..098f469656 100644 --- a/packages/core/e2e/shop-auth.e2e-spec.ts +++ b/packages/core/e2e/shop-auth.e2e-spec.ts @@ -61,16 +61,16 @@ class TestEmailPlugin implements OnModuleInit { onModuleInit() { this.eventBus.ofType(AccountRegistrationEvent).subscribe(event => { - sendEmailFn(event); + sendEmailFn?.(event); }); this.eventBus.ofType(PasswordResetEvent).subscribe(event => { - sendEmailFn(event); + sendEmailFn?.(event); }); this.eventBus.ofType(IdentifierChangeRequestEvent).subscribe(event => { - sendEmailFn(event); + sendEmailFn?.(event); }); this.eventBus.ofType(IdentifierChangeEvent).subscribe(event => { - sendEmailFn(event); + sendEmailFn?.(event); }); } } diff --git a/packages/core/src/service/services/customer.service.ts b/packages/core/src/service/services/customer.service.ts index cc0f116156..2bffe9dec9 100644 --- a/packages/core/src/service/services/customer.service.ts +++ b/packages/core/src/service/services/customer.service.ts @@ -263,9 +263,8 @@ export class CustomerService { customer.user = result; } } - } else { - this.eventBus.publish(new AccountRegistrationEvent(ctx, customer.user)); } + this.eventBus.publish(new AccountRegistrationEvent(ctx, customer.user)); await this.channelService.assignToCurrentChannel(customer, ctx); const createdCustomer = await this.connection.getRepository(ctx, Customer).save(customer); await this.customFieldRelationService.updateRelations(ctx, Customer, input, createdCustomer);