addBreadcrumb("/home", __("Log In")); $user = $core->getUser(); if($user) { Http::redirect("/dashboard"); } $request = Request::fromPost(); $email = $request->email("email"); $password = $request->raw("password"); if($email) { try { $user = User::queryOne(["email" => $email]); if(!$user) { throw new RuntimeException(__("The credentials supplied do not match any records on the system.")); } if(!$user->validatePassword($password)) { throw new RuntimeException(__("The credentials supplied do not match any records on the system.")); } $_SESSION["user_id"] = $user->id; Session::addAlert("success", __("Logged in successfully.")); Http::redirect("/dashboard"); } catch(\Exception $e) { Session::addAlert("danger", $e->getMessage()); } } View::include("header"); View::include("home"); View::include("footer");