appcode = $appcode; } protected $appcode; protected $userManager; protected function getUserManager(): IUserManager { if ($this->userManager === null) { $class = static::USER_MANAGER_CLASS; $this->userManager = func::cons($class, $this->appcode); } return $this->userManager; } private $destPage = null; function beforeSetup(AInitAuthzPage $page): void { # initialiser la session avant setup. ainsi, dans les fonction beforeSetup(), # setup() et afterSetup(), la session est disponible $this->destPage = F::get("d", $page->getMainUrl()); $this->checkSession($username, $authType); if ($authType === "cas" && F::get("a")) { # autologin $casauthUrl = config::k("url")."/".$page->getCasauthUrl(); page::redirect(page::bu($page->getCasLoginUrl(), [ "service" => page::bu($casauthUrl, [ "r" => $page->getLoginUrl(), "d" => $this->destPage, ]) ])); } } function print(AInitAuthzPage $page): void { page::no_cache(); ly::row(); vo::h1(["class" => "text-center", q($page->TITLE())]); ly::col(["sm" => 6, "sm-push" => 3]); $status = $this->getStatus(); switch ($status) { case authz::DISCONNECTED: msg::warning("Vous avez été déconnecté. Veuillez vous reconnecter"); break; case authz::UNAUTHORIZED: msg::error(["user" => [ "Connecté en tant que ", v::b($this->getAuth()), ", vous n'êtes pas autorisé à accéder à la page que vous avez demandé.", ]]); break; } ly::panel("Connexion par CAS"); if ($page->isDevauthAllowed()) { fo::start([ "type" => "basic", "action" => $page->getCasauthUrl(), "method" => "get", ]); fo::hidden("r", $page->getLoginUrl()); fo::hidden("d", $this->destPage); } else { fo::start([ "type" => "basic", "action" => $page->getCasLoginUrl(), "method" => "get", ]); $casauthUrl = config::k("url")."/".$page->getCasauthUrl(); fo::hidden("service", page::bu($casauthUrl, [ "r" => $page->getLoginUrl(), "d" => $this->destPage, ])); } #fo::p("Si vous avez un compte à l'université, vous pouvez vous connecter via CAS"); vo::p("Si vous avez un compte à l'université, vous pouvez vous connecter via CAS"); if ($this->isAuth()) { if ($status != authz::UNAUTHORIZED) { msg::warning(["user" => [ "Connecté en tant que ", v::b(authz::get_auth()), ", vous n'êtes pas autorisé à accéder à cette application.", ]]); } fo::submit([ icon::logout("Vous déconnecter"), "formaction" => $page->getLogoutUrl(), "accesskey" => "z", ]); fo::hidden("renew", "true"); fo::submit([ icon::login("Changer de compte"), "accesskey" => "r", ]); } else { fo::submit(["Connexion par CAS", "accesskey" => "r"]); } fo::end(); ly::end(); } }