SessionCas.php (mrbs-1.9.4) | : | SessionCas.php (mrbs-1.10.0) | ||
---|---|---|---|---|
<?php | <?php | |||
namespace MRBS\Session; | namespace MRBS\Session; | |||
use MRBS\User; | ||||
use \phpCAS; | use \phpCAS; | |||
use MRBS\Form\Form; | use MRBS\Form\Form; | |||
class SessionCas extends SessionWithLogin | class SessionCas extends SessionWithLogin | |||
{ | { | |||
public function __construct() | public function __construct() | |||
{ | { | |||
$this->checkTypeMatchesSession(); | $this->checkTypeMatchesSession(); | |||
\MRBS\auth()->init(); // Initialise CAS | \MRBS\auth()->init(); // Initialise CAS | |||
parent::__construct(); | parent::__construct(); | |||
} | } | |||
public function authGet($target_url=null, $returl=null, $error=null, $raw=fals e) | public function authGet(?string $target_url=null, ?string $returl=null, ?strin g $error=null, bool $raw=false) : void | |||
{ | { | |||
// Useless Method - CAS does it all | // Useless Method - CAS does it all | |||
} | } | |||
public function getCurrentUser() | public function getCurrentUser() : ?User | |||
{ | { | |||
return (phpCAS::isAuthenticated()) ? \MRBS\auth()->getUser(phpCAS::getUser() ) : null; | return (phpCAS::isAuthenticated()) ? \MRBS\auth()->getUser(phpCAS::getUser() ) : null; | |||
} | } | |||
public function getLogonFormParams() | public function getLogonFormParams() : ?array | |||
{ | { | |||
$target_url = \MRBS\this_page(true); | $target_url = \MRBS\this_page(true); | |||
return array( | return array( | |||
'action' => $target_url, | 'action' => $target_url, | |||
'method' => 'post', | 'method' => 'post', | |||
'hidden_inputs' => array('target_url' => $target_url, | 'hidden_inputs' => array('target_url' => $target_url, | |||
'action' => 'QueryName') | 'action' => 'QueryName') | |||
); | ); | |||
} | } | |||
public function processForm() | public function processForm() : void | |||
{ | { | |||
if (isset($this->form['action'])) | if (isset($this->form['action'])) | |||
{ | { | |||
// Target of the form with sets the URL argument "action=QueryName". | // Target of the form with sets the URL argument "action=QueryName". | |||
if ($this->form['action'] == 'QueryName') | if ($this->form['action'] == 'QueryName') | |||
{ | { | |||
phpCAS::forceAuthentication(); | phpCAS::forceAuthentication(); | |||
} | } | |||
// Target of the form with sets the URL argument "action=SetName". | // Target of the form with sets the URL argument "action=SetName". | |||
skipping to change at line 65 | skipping to change at line 66 | |||
// You should only get here using CAS authentication after clicking the logoff | // You should only get here using CAS authentication after clicking the logoff | |||
// link, no matter what the value of the form parameters. | // link, no matter what the value of the form parameters. | |||
$this->logoffUser(); | $this->logoffUser(); | |||
\MRBS\location_header($this->form['target_url']); // Redirect browser to initial page | \MRBS\location_header($this->form['target_url']); // Redirect browser to initial page | |||
} | } | |||
} | } | |||
} | } | |||
public function logoffUser() | public function logoffUser() : void | |||
{ | { | |||
phpCAS::logout(); | phpCAS::logout(); | |||
} | } | |||
} | } | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 6 lines changed or added |