- Reworked the tenant admin login page

- Updated the User model to implement Filament’s tenancy contracts
- Seeded a ready-to-use demo tenant (user, tenant, active package, purchase)
- Introduced a branded, translated 403 error page to replace the generic forbidden message for unauthorised admin hits
- Removed the public “Register” links from the marketing header
- hardened join event logic and improved error handling in the guest pwa.
This commit is contained in:
Codex Agent
2025-10-13 12:50:46 +02:00
parent 9394c3171e
commit 64a5411fb9
69 changed files with 5447 additions and 588 deletions

View File

@@ -2,91 +2,60 @@
namespace App\Filament\Pages\Auth;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\SimplePage;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Filament\Auth\Pages\Login as BaseLogin;
use Filament\Schemas\Components\Component;
class Login extends SimplePage implements HasForms
class Login extends BaseLogin
{
use InteractsWithForms;
protected string $view = 'filament.pages.auth.login';
protected static ?string $title = 'Tenant Login';
public function getFormSchema(): array
public function getTitle(): string
{
return [
TextInput::make('data.username_or_email')
->label('Username or Email')
->required()
->autofocus(),
TextInput::make('data.password')
->password()
->required()
->extraAttributes(['tabindex' => 2]),
Checkbox::make('data.remember')
->label('Remember me'),
];
return __('auth.login.title') ?: parent::getTitle();
}
public function submit(): void
public function getHeading(): string
{
$data = $this->form->getState();
return __('auth.login.title') ?: parent::getHeading();
}
$credentials = $this->getCredentialsFromFormData($data);
protected function getEmailFormComponent(): Component
{
$component = parent::getEmailFormComponent();
if (! Auth::attempt($credentials, $data['remember'] ?? false)) {
throw ValidationException::withMessages([
'data.username_or_email' => __('auth.failed'),
]);
}
return $component
->label(__('auth.login.username_or_email') ?: $component->getLabel());
}
$user = Auth::user();
protected function getPasswordFormComponent(): Component
{
$component = parent::getPasswordFormComponent();
if (! $user->email_verified_at) {
Auth::logout();
return $component
->label(__('auth.login.password') ?: $component->getLabel());
}
throw ValidationException::withMessages([
'data.username_or_email' => 'Your email address is not verified. Please check your email for a verification link.',
]);
}
protected function getRememberFormComponent(): Component
{
$component = parent::getRememberFormComponent();
if (! $user->tenant) {
Auth::logout();
throw ValidationException::withMessages([
'data.username_or_email' => 'No tenant associated with your account. Contact support.',
]);
}
session()->regenerate();
$this->redirect($this->getRedirectUrl());
return $component
->label(__('auth.login.remember_me') ?: $component->getLabel());
}
protected function getCredentialsFromFormData(array $data): array
{
$usernameOrEmail = $data['username_or_email'];
$password = $data['password'];
$identifier = $data['email'] ?? '';
$password = $data['password'] ?? '';
$credentials = ['password' => $password];
if (filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL)) {
$credentials['email'] = $usernameOrEmail;
} else {
$credentials['username'] = $usernameOrEmail;
if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
return [
'email' => $identifier,
'password' => $password,
];
}
return $credentials;
return [
'username' => $identifier,
'password' => $password,
];
}
public function hasLogo(): bool
{
return false;
}
}