Rewrite the layout and all Customers and Users pages with TallStackUI components and remove livewire/flux and its Boost skill. Fix the TallStackUI accessibility gaps found by the axe tests: - password reveal and theme switch have no accessible name: add <x-password-field> and keep the own theme toggle button - select.native label is not tied to the control: add aria-label - contrast: darker primary palette, soft-customized error colours and published alert/link colour classes; neutral buttons use subtle black - follow the system theme by default (localStorage key dark-theme) Load TallStackUI assets from the app URL so they work in the XAMPP subfolder, add Finnish TallStackUI strings, and drop inputmode=numeric from the business ID field so iOS keyboards show the hyphen. Co-Authored-By: Claude Opus 5.5 <[email protected]>
115 lines
3.6 KiB
PHP
115 lines
3.6 KiB
PHP
<?php
|
|
|
|
use App\Modules\Users\Application\UseCases\CheckLoginAllowed;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Livewire\Component;
|
|
|
|
new class extends Component
|
|
{
|
|
public const int MAX_ATTEMPTS_PER_MINUTE = 5;
|
|
|
|
public string $email = '';
|
|
|
|
public string $password = '';
|
|
|
|
public bool $remember = false;
|
|
|
|
/**
|
|
* Set when EnsureAccountIsUsable ended the session. Passed in the URL,
|
|
* not flashed: a Livewire request that gets redirected here would
|
|
* consume a flash message before the browser shows the page.
|
|
*/
|
|
public bool $accessEnded = false;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->accessEnded = request()->query('access') === 'ended';
|
|
}
|
|
|
|
public function login(CheckLoginAllowed $checkLoginAllowed): void
|
|
{
|
|
$this->email = trim($this->email);
|
|
|
|
$this->validate(
|
|
['email' => ['required', 'string', 'email'], 'password' => ['required', 'string']],
|
|
[
|
|
'email.required' => __('auth.email_required'),
|
|
'email.email' => __('auth.email_invalid'),
|
|
'password.required' => __('auth.password_required'),
|
|
],
|
|
);
|
|
|
|
$email = Str::lower(trim($this->email));
|
|
$throttleKey = Str::transliterate($email.'|'.request()->ip());
|
|
|
|
if (RateLimiter::tooManyAttempts($throttleKey, self::MAX_ATTEMPTS_PER_MINUTE)) {
|
|
throw ValidationException::withMessages([
|
|
'email' => __('auth.throttle', ['seconds' => RateLimiter::availableIn($throttleKey)]),
|
|
]);
|
|
}
|
|
|
|
$signedIn = Auth::attemptWhen(
|
|
['email' => $email, 'password' => $this->password],
|
|
fn ($user): bool => $checkLoginAllowed->execute($user->getAuthIdentifier()),
|
|
$this->remember,
|
|
);
|
|
|
|
if (! $signedIn) {
|
|
RateLimiter::hit($throttleKey);
|
|
$this->reset('password');
|
|
|
|
// One message for a wrong password and a disabled account, so the
|
|
// form never confirms that a disabled account's password is right.
|
|
throw ValidationException::withMessages(['email' => __('auth.failed')]);
|
|
}
|
|
|
|
RateLimiter::clear($throttleKey);
|
|
session()->regenerate();
|
|
|
|
$this->redirectIntended(route('home'));
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__('auth.login_title'));
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="mx-auto max-w-md space-y-6 p-4 sm:p-6 sm:pt-16">
|
|
<h1 class="text-2xl font-semibold">{{ __('auth.login_title') }}</h1>
|
|
|
|
@if ($accessEnded)
|
|
<x-alert role="status" color="yellow" light icon="exclamation-triangle" :text="__('auth.account_disabled')" />
|
|
@elseif (session('status'))
|
|
<x-alert role="status" color="green" light icon="information-circle" :text="session('status')" />
|
|
@endif
|
|
|
|
<form wire:submit="login" class="space-y-6" novalidate>
|
|
<x-input
|
|
wire:model="email"
|
|
type="email"
|
|
:label="__('auth.email')"
|
|
autocomplete="username"
|
|
required
|
|
/>
|
|
|
|
<x-password-field
|
|
wire:model="password"
|
|
:label="__('auth.password_label')"
|
|
autocomplete="current-password"
|
|
required
|
|
/>
|
|
|
|
<x-checkbox wire:model="remember" :label="__('auth.remember')" />
|
|
|
|
<div class="flex flex-wrap items-center justify-between gap-4">
|
|
<x-button submit :text="__('auth.login')" />
|
|
<x-link :href="route('password.request')" navigate :text="__('auth.forgot_password')" />
|
|
</div>
|
|
</form>
|
|
</div>
|