Commit 337919a0 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Si CAS est le seul type d'authentification alors le lien de connexion envoie...

Si CAS est le seul type d'authentification alors le lien de connexion envoie directement vers le CAS sans passer par la sélection du type
parent 830992c3
Loading
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
# UnicaenAuth
***UnicaenAuth***
---

**CHANGES**
---

**5.0.2** 
* Si CAS est le seul type d'authentification alors le lien de connexion envoie directement vers le CAS sans passer par la sélection du type

---
Ce module :

- ajoute à une application la possibilité d'identifier/authentifier l'utilisateur (LDAP, base de données ou CAS).
+3 −1
Original line number Diff line number Diff line
@@ -11,6 +11,8 @@ use UnicaenUtilisateur\View\Helper\UserAbstract;
 */
class UserConnection extends UserAbstract
{
    public bool $onlyCas = false;

    /**
     * Point d'entrée.
     *
@@ -18,7 +20,6 @@ class UserConnection extends UserAbstract
     */
    public function __invoke()
    {
        return $this;
    }

    /**
@@ -47,6 +48,7 @@ class UserConnection extends UserAbstract
        $template = '<a class="navbar-link user-connection" href="%s" title="%s">%s</a>';
        if (!$identity) {
            $href  = $urlHelper('zfcuser/login');
            if ($this->onlyCas) $href = $urlHelper('zfcuser/authenticate',['type' => 'cas']);
            $lib   = "Connexion";
            $title = "Affiche le formulaire d'authentification";
        }
+10 −1
Original line number Diff line number Diff line
@@ -20,8 +20,17 @@ class UserConnectionFactory implements FactoryInterface

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $config = $container->get('Config')['unicaen-auth'];
        $activeModes = [];
        foreach ($config['auth_types'] as $type) {
            if ($config[$type]['enabled']) $activeModes[] = $type;
        }
        $onlyCas = (count($activeModes) === 1 AND $activeModes[0] === 'cas');

        $authUserContext = $container->get('authUserContext');

        return new UserConnection($authUserContext);
        $uc = new UserConnection($authUserContext);
        $uc->onlyCas = $onlyCas;
        return $uc;
    }
}
 No newline at end of file