protected function doLogin($r) { $post = $this->jsonpost(); Input::ensureRequest($post, array("username", "password")); if (($user = $this->login($post["username"], $post["password"])) !== false) { Session::Set(self::userid, $user); Session::addRight(self::logged); if (Session::Has(Session::rights_key)) { $rights = Session::Get(Session::rights_key); } else { $rights = array(); } Output::success(array("user" => $user, "rights" => $rights)); } ErrorHandler::error(401); }
public function cf_options($keys = null) { if ($keys == null) { $keys = array(); foreach (Options::getAll() as $key => $val) { if (substr($key, -5) == "_PATH") { $keys[] = $key; } } } $options = array(); foreach (Options::getAll() as $key => $val) { if (in_array($key, $keys)) { $options[strtolower($key)] = $val; } } if (Session::Has(Session::rights_key)) { $options["rights"] = Session::Get(Session::rights_key); } else { $options["rights"] = array(); } if (Session::Has(AbstractLogin::userid)) { $options["user"] = Session::Get(AbstractLogin::userid); } else { $options["user"] = false; } foreach (Plugins::dispatchAll("cf_options") as $opt) { $options = array_merge($options, $opt); } echo json_encode($options); }