Skip to content

Commit

Permalink
fix: removeEmail in mikro-orm adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
darkbasic committed Nov 22, 2023
1 parent a719783 commit 2282086
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/database-mikro-orm/src/mikro-orm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,13 @@ export class AccountsMikroOrm<
}

public async removeEmail(userId: string, email: string): Promise<void> {
const deleted = this.em.remove({ address: email.toLocaleLowerCase() });
if (!deleted) {
try {
this.em.remove(
await this.emailRepository.findOneOrFail({
address: email.toLocaleLowerCase(),
})
);
} catch {
throw new Error('Email not found');
}
return this.em.flush();
Expand Down

0 comments on commit 2282086

Please sign in to comment.