form->getState(); $credentials = $this->getCredentialsFromFormData($data); $authGuard = Filament::auth(); if (! $authGuard->attempt($credentials, $data['remember'] ?? false)) { throw ValidationException::withMessages([ 'data.email' => __('auth.failed'), ]); } $user = $authGuard->user(); if (! $user->email_verified_at) { $authGuard->logout(); throw ValidationException::withMessages([ 'data.email' => 'Your email address is not verified. Please check your email for a verification link.', ]); } // SuperAdmin-spezifisch: Prüfe auf SuperAdmin-Rolle, keine Tenant-Prüfung if (! $user->isSuperAdmin()) { $authGuard->logout(); throw ValidationException::withMessages([ 'data.email' => 'You do not have access to the SuperAdmin panel. Contact support.', ]); } session()->regenerate(); return parent::getLoggedInResponse(); } protected function getRedirectUrl(): string { return '/super-admin'; } protected function getCredentialsFromFormData(array $data): array { return [ 'email' => $data['data']['email'], 'password' => $data['data']['password'], ]; } public function getFormSchema(): array { return [ TextInput::make('data.email') ->label('Email') ->email() ->required() ->autofocus(), TextInput::make('data.password') ->label('Password') ->password() ->required() ->extraAttributes(['tabindex' => 2]), Checkbox::make('data.remember') ->label('Remember me'), ]; } }