Files
servicedesk/src/app/Livewire/Auth/Login.php
Kacper 03c6ec7cae v1.4.0
Co nowego:
- Wsparcie Active Directory dla LDAP (obok LLDAP/OpenLDAP), przełącznik typu
  katalogu w Admin > Integracje.
- Wyszukiwarka klientów dla operatora (Operator > Klienci).
- Stronicowanie kolejki operatora (50/stronę) i dashboardu klienta (20/stronę).
- Globalna wyszukiwarka zgłoszeń (Ctrl+K/Cmd+K) z operatorami w stylu Gmaila
  (od:, temat:, treść:, numer:), plus przycisk "Szukaj" w panelu bocznym.
- Ostatnio przeglądane zgłoszenia w panelu bocznym operatora.
- Przeprojektowany pasek nawigacji: suwak Klient/Operator/Administrator
  zamiast rozwijanego menu, bogatsze menu profilu (nazwa/e-mail/role),
  dynamiczne tytuły kart przeglądarki na każdej podstronie.
- Narzędzie do jednorazowego importu historii zgłoszeń z Heska 3.x
  (scripts/hesk-import/).
- Poprawka: paginacja pokazywała surowe klucze tłumaczeń zamiast tekstu
  (brakujący lang/pl/pagination.php).

Zaktualizowana dokumentacja: README, CLAUDE.md, install.md, ARCHITECTURE.md,
CHANGELOG.md, wiki/*.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-05 00:58:35 +02:00

81 lines
2.4 KiB
PHP

<?php
namespace App\Livewire\Auth;
use App\Support\Settings;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Url;
use Livewire\Component;
class Login extends Component
{
public string $username = '';
public string $password = '';
public ?string $error = null;
/**
* Where to land after a successful login — e.g. set by the guest ticket
* confirmation screen's "Zaloguj się" button so it can jump straight to
* the just-created ticket instead of the user's default area.
*/
#[Url]
public ?string $redirect = null;
public function submit(): void
{
$this->error = null;
// The form also has HTML `required` attributes so the browser blocks
// an empty submit before it ever reaches here, but that's only a UX
// nicety — nothing stops a request hitting this method directly, so
// it needs to fail closed on its own too.
if (trim($this->username) === '' || $this->password === '') {
$this->error = 'Podaj nazwę użytkownika i hasło.';
return;
}
$attribute = Settings::ldapUsernameAttribute();
// Local accounts (created with a password from the admin panel) don't
// necessarily exist in LDAP under this attribute, so we also let the
// provider fall back to matching by e-mail + local password.
$ok = Auth::attempt([
$attribute => $this->username,
'password' => $this->password,
'fallback' => ['email' => $this->username],
]);
if (! $ok) {
$this->error = 'Nieprawidłowa nazwa użytkownika lub hasło.';
$this->password = '';
return;
}
request()->session()->regenerate();
$this->redirect($this->safeRedirectTarget() ?? Auth::user()->defaultArea(), navigate: false);
}
/**
* Only follow the ?redirect= target when it's a same-app relative path —
* never an absolute/external URL, to avoid it being abused as an open redirect.
*/
protected function safeRedirectTarget(): ?string
{
if (! $this->redirect || ! str_starts_with($this->redirect, '/') || str_starts_with($this->redirect, '//')) {
return null;
}
return $this->redirect;
}
public function render()
{
return view('livewire.auth.login')->title(Settings::pageTitle('Logowanie'));
}
}