public function onCalled($route) { $isInstallPage = trim($route->getPath(), '/') == "install"; $isServerInstalled = file_exists("config/server.json"); if ($isInstallPage) { if ($isServerInstalled) { return new RedirectResponse(Paladin::getRootPath(true) . "panel"); } else { return false; } } else { if ($isServerInstalled) { return false; } else { return new RedirectResponse(Paladin::getRootPath(true) . "install"); } } }
public function onCalled($route) { $isLoginPage = trim($route->getPath(), '/') == "auth/login"; $isUserLogged = isset($_SESSION["logged"]) && $_SESSION["logged"] == true; if ($isLoginPage) { if ($isUserLogged) { return new RedirectResponse(Paladin::getRootPath(true) . "/panel"); } else { return false; } } else { if ($isUserLogged) { return false; } else { return new RedirectResponse(Paladin::getRootPath(true) . "auth/login"); } } }
* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with S-Update-Server. If not, see <http://www.gnu.org/licenses/>. */ use Paladin\Http\RedirectResponse; use Paladin\Http\Response; use Paladin\Paladin; use SUpdateServer\SUpdateServer; $this->get("/", function () { return new RedirectResponse(Paladin::getRootPath(true) . "panel"); }); $this->get("/panel", function () { return new RedirectResponse(Paladin::getRootPath(true) . "panel/home"); }); $this->get("/panel/:request", ["middleware" => ["install", "auth"], "uses" => "PanelController@getPanel"]); $this->post("/panel/:request", ["middleware" => ["install", "auth"], "uses" => "PanelController@postPanel"]); $this->get("/aubergine", function () { return new RedirectResponse("http://www.google.fr/search?q=aubergine"); }); $this->get("/auth/logout", ["middleware" => ["install", "auth"], "uses" => "AuthController@logout"]); $this->get("/auth/login", ["middleware" => ["install", "auth"], "uses" => "AuthController@getLogin"]); $this->post("/auth/login", ["middleware" => ["install"], "uses" => "AuthController@postLogin"]); // Internal routes $this->get("/set-enabled/:enabled", ["middleware" => ["install", "auth"], "uses" => function ($enabled) { Paladin::config("server")->set("enabled", $enabled == "true"); return new Response(); }]); $this->get("/install", ["middleware" => "install", "uses" => "InstallController@getInstall"]);