whisper-money/app/Models
Víctor Falcón 690be20f21
feat(open-banking): add update credentials flow for API-key connections (#154)
## Why

### Problem

When API tokens for Indexa Capital, Binance, or Bitpanda expire or are
revoked, syncs fail silently with 401/403 errors. Users have no way to
replace their credentials without disconnecting and recreating the
entire connection (losing account mappings and history).

## What

### Changes

- **Auth failure email notification**: on the final retry attempt (3rd
of 3), if a sync job fails with 401/403 for an API-key provider, an
email is sent to the user with a link to the connections settings page
- **Update credentials endpoint**: `PATCH
/settings/connections/{connection}/credentials` validates new
credentials against the provider API before saving, then triggers a sync
- **Update credentials dialog**: provider-specific form (API token for
Indexa/Bitpanda, API key + secret for Binance) shown via an "Update
Credentials" button in the error banner and dropdown menu
- **Mailable**: `BankingConnectionAuthFailedEmail` follows existing
patterns (queued, rate-limited, Markdown template)
- **Form request**: `UpdateConnectionCredentialsRequest` with dynamic
validation rules per provider and authorization check

### Files changed

| File | Change |
|------|--------|
| `app/Jobs/SyncBankingConnectionJob.php` | Send auth failed email on
final attempt for auth errors on API-key providers |
| `app/Mail/BankingConnectionAuthFailedEmail.php` | New queued mailable
|
| `resources/views/mail/banking-connection-auth-failed.blade.php` |
Email template |
| `app/Http/Controllers/OpenBanking/ConnectionController.php` |
`updateCredentials()` action with provider credential validation |
| `app/Http/Requests/OpenBanking/UpdateConnectionCredentialsRequest.php`
| Dynamic validation per provider |
| `routes/settings.php` | PATCH route for credential updates |
| `resources/js/components/open-banking/update-credentials-dialog.tsx` |
Dialog with provider-specific fields |
| `resources/js/pages/settings/connections.tsx` | Update Credentials
button in error state and dropdown |

## Verification

### Tests

- **12 new tests** across 2 test files, all passing:
- `SyncBankingConnectionJobTest`: 5 tests covering email sent on final
retry (Indexa 401, Binance 403), not sent before final retry, not sent
for non-auth errors, not sent for EnableBanking
- `ConnectionControllerTest`: 7 tests covering valid credential update
for each provider, invalid credentials, EnableBanking rejection,
authorization, feature flag, required field validation
- Full OpenBanking test suite: **145 tests, 473 assertions** passing
2026-02-25 13:41:24 +01:00
..
Account.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
AccountBalance.php feat: investment benefits — show gains/losses on investment accounts (#140) 2026-02-23 13:59:10 +01:00
AutomationRule.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
AutomationRuleLabel.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
Bank.php Migrate ID's to UUIDv7 2025-11-15 21:25:33 +01:00
BankingConnection.php feat(open-banking): add update credentials flow for API-key connections (#154) 2026-02-25 13:41:24 +01:00
Budget.php fix: Budget period not found on last day of period (#91) 2026-02-01 11:33:10 +01:00
BudgetPeriod.php feat: Load transactions history on budget created (#72) 2026-01-22 11:10:15 +01:00
BudgetTransaction.php Add Budgeting Feature to Track and Manage Spending (#36) 2026-01-21 15:25:50 +01:00
Category.php Add type enum to categories 2025-12-01 10:29:57 +01:00
EncryptedMessage.php Migrate ID's to UUIDv7 2025-11-15 21:25:33 +01:00
ExchangeRate.php feat: Add multi-currency conversion for net worth charts (#138) 2026-02-20 10:45:23 +01:00
Label.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
LabelTransaction.php feat: add transaction labels feature (#24) 2025-12-13 13:02:19 +01:00
Transaction.php Move transaction filtering from client-side to server-side (#126) 2026-02-16 12:49:04 +01:00
User.php feat: Integrate EnableBanking as open banking provider (#106) 2026-02-12 09:09:28 +01:00
UserLead.php Merge pull request #1 from whisper-money/landing-page 2025-11-24 12:11:35 +01:00
UserMailLog.php feat: Send custom emails to users (#52) 2026-01-09 09:33:19 +01:00