Skip to content

Commit

Permalink
chore: Disallow account deletion if there are active recurring payments
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Sep 2, 2024
1 parent 2d24a81 commit 6e9b55d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/api/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ export class AuthService {
)
}

if (user.recurringDonations.length) {
throw new ForbiddenException(
`Account cannot be deleted due to active recurring payments. Please cancel all recurring payments before deleting this account`,
)
}

return this.authenticateAdmin()
.then(() => this.admin.users.del({ id: keycloakId }))
.then(() => this.personService.softDelete(user.id))
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/person/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class PersonService {
company: true,
beneficiaries: { select: { id: true } },
organizer: { select: { id: true } },
recurringDonations: { select: { id: true } },
},
})
}
Expand Down

0 comments on commit 6e9b55d

Please sign in to comment.