79 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| namespace nur\b\authnz;
 | |
| 
 | |
| use nur\authz;
 | |
| use nur\config;
 | |
| use nur\F;
 | |
| use nur\msg;
 | |
| use nur\v\fo;
 | |
| use nur\v\ly;
 | |
| use nur\v\page;
 | |
| use nur\v\v;
 | |
| use nur\v\vo;
 | |
| use nur\v\vp\AInitAuthzPage;
 | |
| 
 | |
| class ExtAuthzManager extends AuthzManager {
 | |
|   const USER_MANAGER_CLASS = ExtUserManager::class;
 | |
| 
 | |
|   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 === "ext" && F::get("a")) {
 | |
|       # autologin
 | |
|       $extauthUrl = config::k("url")."/".$page->getExtauthUrl();
 | |
|       page::redirect(page::bu($extauthUrl, [
 | |
|         "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");
 | |
|     fo::start([
 | |
|       "type" => "basic",
 | |
|       "action" => $page->getExtauthUrl(),
 | |
|       "method" => "get",
 | |
|     ]);
 | |
|     fo::hidden("d", $this->destPage);
 | |
|     vo::p("Si vous avez un compte à l'université, vous pouvez vous connecter");
 | |
|     if ($this->isAuth()) {
 | |
|       if ($status != authz::UNAUTHORIZED) {
 | |
|         msg::warning(["user" => [
 | |
|           "Connecté en tant que ",
 | |
|           v::b($this->getAuth()),
 | |
|           ", vous n'êtes pas autorisé à accéder à cette application.",
 | |
|         ]]);
 | |
|       }
 | |
|     } else {
 | |
|       fo::submit(["Connexion", "accesskey" => "r"]);
 | |
|     }
 | |
|     fo::end();
 | |
| 
 | |
|     ly::end();
 | |
|   }
 | |
| }
 |