error = null; $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'); } }