Skip to content

Commit

Permalink
fix(core): Publish AccountRegistrationEvent when creating Customer vi…
Browse files Browse the repository at this point in the history
…a admin

Co-authored-by: stefanfeldner <stefanfeldner@gmail.com>
  • Loading branch information
michaelbromley and stefanfeldner authored Jul 25, 2023
1 parent 164ac76 commit e0bd036
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/core/e2e/customer.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class TestEmailPlugin implements OnModuleInit {

onModuleInit() {
this.eventBus.ofType(AccountRegistrationEvent).subscribe(event => {
sendEmailFn(event);
sendEmailFn?.(event);
});
}
}
Expand Down Expand Up @@ -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 () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/e2e/shop-auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/service/services/customer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e0bd036

Please sign in to comment.