whisper-money/app/Http/Controllers/Settings
Víctor Falcón 2bfb569a22
fix(account): block deletion while subscription or trial is active (#531)
## Problem

Self-deleting an account via **Settings → Delete account** only called
`markAsDeleted()`. It never checked or cancelled the Stripe
subscription, so a user could delete their account while still
subscribed and **keep getting billed** afterwards. The `user:delete` CLI
command already cancelled the subscription, but the web path never got
that logic.

## Fix

Block account deletion while the user is **on a trial** or holds a
**valid, uncancelled subscription**, and direct them to cancel via the
billing portal first.

- `User::hasActiveSubscriptionOrTrial()` — true on a trial or a
`valid()` subscription; **grace-period** (already-cancelled)
subscriptions are excluded since they won't re-bill, so deletion is
still allowed.
- `ProfileController::destroy()` — rejects with a `subscription` error
before deleting (server-side guard, also covers non-UI calls).
- Delete-account page now receives `hasActiveSubscriptionOrTrial`; when
set, the UI shows a warning + **Manage billing** link and hides the
delete dialog.
- Spanish translations added for the two new strings.

The `user:delete` CLI is unchanged — it keeps its
auto-cancel-with-confirmation flow for admin use.

## Tests

- Active subscription → deletion blocked
- Trialing subscription → deletion blocked
- Grace-period (cancelled) subscription → deletion allowed
- Delete-account page exposes the flag (true/false)

All passing locally, alongside Pint / Prettier / ESLint.
2026-06-14 20:46:44 +02:00
..
AccountController.php refactor(api): standardize serialization via model $hidden (#492) 2026-06-05 13:57:34 +02:00
AutomationRuleApplicationController.php refactor(api): standardize serialization via model $hidden (#492) 2026-06-05 13:57:34 +02:00
AutomationRuleController.php Apply automation rules to existing transactions (#413) 2026-05-22 08:36:18 +02:00
BankController.php refactor(banks): add Bank::availableForUser scope (#480) 2026-06-03 17:59:24 +02:00
CategoryController.php feat: enable category tree for all users, remove flag (#488) 2026-06-04 13:44:57 +02:00
ChartColorSchemeController.php Add chart color scheme setting (#101) 2026-02-28 12:58:21 +01:00
LabelController.php refactor(api): standardize serialization via model $hidden (#492) 2026-06-05 13:57:34 +02:00
NetWorthChartLoanPreferenceController.php fix(dashboard): treat loans as debt in net worth (#238) 2026-03-20 09:55:53 +00:00
NetWorthChartRealEstatePreferenceController.php feat(accounts): add real estate asset tracking (#241) 2026-03-24 10:21:32 +00:00
NotificationPreferenceController.php feat(settings): let users disable bank transactions email (#472) 2026-06-02 12:24:39 +02:00
PasswordController.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00
ProfileController.php fix(account): block deletion while subscription or trial is active (#531) 2026-06-14 20:46:44 +02:00
TimezoneController.php fix(user): persist detected timezones (#296) 2026-04-16 11:36:57 +01:00
TwoFactorAuthenticationController.php Set up a fresh Laravel app 2025-11-07 12:01:36 +00:00