whisper-money/tests/Feature/Auth
Víctor Falcón 96ee311299
fix(register): don't block signup on unrecognized browser timezone (#462)
## Problem

Some users reported they couldn't register: they filled the form
correctly, pressed the button, saw a loading spinner, then got bounced
back to the registration page with **no error message**. Meanwhile 20-30
users register fine every day, and the issue wasn't reproducible by the
team.

## Root cause

The register form sends a **hidden, browser-auto-detected `timezone`**
field (`Intl.DateTimeFormat().resolvedOptions().timeZone`). The backend
validated it with Laravel's `timezone` rule:

```php
'timezone' => ['nullable', 'string', 'timezone'],
```

That rule rejects **legacy IANA aliases** that many browsers/OSes still
emit — e.g. `Asia/Calcutta`, `Asia/Saigon`, `Asia/Rangoon`,
`US/Pacific`. Proof on PHP 8.4:

```
in_array("Asia/Calcutta", DateTimeZone::listIdentifiers())  →  false
```

When validation failed, Fortify redirected back with a `timezone` error
— but the form had **no error display** for timezone (every other field
has one). Result: spinner → silent bounce → no message → and the user
can't fix a hidden field anyway. The team couldn't reproduce because
their browsers send canonical zones that pass. Production tzdata may
reject even more zones.

## Fix

- Stop validating the auto-detected hidden field against the strict
timezone list.
- Add `normalizeTimezone()`: keep recognized zones (including BC aliases
via `DateTimeZone::ALL_WITH_BC`), drop anything unrecognized to `null`.
Registration can never be blocked by it again.
- Surface `errors.timezone` in the form as a safety net so a
hidden-field failure can never be silent in the future.

## Tests

- Legacy alias `Asia/Calcutta` → registers, stored as-is.
- Unrecognized zone → registers, stored `null`.
- All existing registration tests pass (13 passed).
2026-06-01 09:03:15 +02:00
..
AuthenticationTest.php Support soft-deleted users with reusable emails (#316) 2026-04-22 11:41:41 +01:00
EmailVerificationTest.php feat: Enable email verification on sign up (#97) 2026-02-03 10:15:07 +01:00
PasswordConfirmationTest.php fix: route new PWA guests to signup (#313) 2026-04-21 10:53:05 +01:00
PasswordResetTest.php E2E Encryption 2025-11-07 14:21:25 +00:00
RegistrationTest.php fix(register): don't block signup on unrecognized browser timezone (#462) 2026-06-01 09:03:15 +02:00
TwoFactorChallengeTest.php E2E Encryption 2025-11-07 14:21:25 +00:00
VerificationNotificationTest.php feat: Enable email verification on sign up (#97) 2026-02-03 10:15:07 +01:00