public function __construct(LoaGuard $auth) { echo '<h2>Access Zone Controller</h2>'; if ($auth->User() != null) { echo '<p>Session LOA= ' . $auth->loa() . ' User= ' . $auth->User()->pseudonym . "</p>"; } else { echo "<p>Session LOA= 0 User= Not Connected</p>"; } }
/** * In a real application each IDP would probably have a dedicated * controller, when for this small demo all of them are build in * one single class. * What ever pattern is used it is important to * build IDP driver in controller class's constructor, even if * you use it only in one method. If not socialuser's object * unserialization will fail. */ public function __construct(IdpFactory $OidConnectFactory, LoaGuard $auth) { $this->auth = $auth; $this->idpfactory = $OidConnectFactory; // build each IDP from resources/config/OidConnect foreach ($this->idpfactory->getConfigByUid(null) as $idpinfo) { $this->idpdriver[$idpinfo['driver']] = $this->idpfactory->driver($idpinfo['driver']); } // an huggly hack to show user current status in each method echo '<h2>Social Login Controller</h2>'; if ($auth->User() != null) { echo '<p>Session LOA= ' . $auth->loa() . ' User= ' . $auth->User()->pseudonym . "</p>"; } else { echo "<p>Session LOA= 0 User= Not Connected</p>"; } }