get('logged_in')) { return redirect()->to('/dashboard'); } if (strtolower($this->request->getMethod()) === 'post') { $email = trim((string) $this->request->getPost('email')); $pass = (string) $this->request->getPost('password'); $okEmail = (string) env('user_email'); $okPass = (string) env('user_password'); if ($okEmail !== '' && hash_equals($okEmail, $email) && hash_equals($okPass, $pass)) { session()->set([ 'logged_in' => true, 'user_email' => $email, ]); return redirect()->to('/dashboard'); } return redirect()->back()->with('error', 'Nieprawidłowy email lub hasło.'); } return view('auth/login'); } public function logout() { session()->destroy(); return redirect()->to('/login'); } }