AuthCas.php (mrbs-1.9.4) | : | AuthCas.php (mrbs-1.10.0) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
class AuthCas extends Auth | class AuthCas extends Auth | |||
{ | { | |||
public function __construct() | public function __construct() | |||
{ | { | |||
$this->checkSessionMatchesType(); | $this->checkSessionMatchesType(); | |||
$this->init(); | $this->init(); | |||
} | } | |||
// Initialise CAS | // Initialise CAS | |||
public function init() | public function init() : void | |||
{ | { | |||
global $auth; | global $auth; | |||
static $init_complete = false; | static $init_complete = false; | |||
if ($init_complete) | if ($init_complete) | |||
{ | { | |||
return; | return; | |||
} | } | |||
skipping to change at line 81 | skipping to change at line 81 | |||
$locale = Locale::parseLocale(\MRBS\get_lang()); | $locale = Locale::parseLocale(\MRBS\get_lang()); | |||
if (isset($cas_lang_map[$locale['language']])) | if (isset($cas_lang_map[$locale['language']])) | |||
{ | { | |||
phpCAS::setLang($cas_lang_map[$locale['language']]); | phpCAS::setLang($cas_lang_map[$locale['language']]); | |||
} | } | |||
$init_complete = true; | $init_complete = true; | |||
} | } | |||
/* authValidateUser($user, $pass) | /* validateUser($user, $pass) | |||
* | * | |||
* Checks if the specified username/password pair are valid | * Checks if the specified username/password pair are valid | |||
* | * | |||
* $user - The user name | * $user - The user name | |||
* $pass - The password | * $pass - The password | |||
* | * | |||
* Returns: | * Returns: | |||
* false - The pair are invalid or do not exist | * false - The pair are invalid or do not exist | |||
* string - The validated username | * string - The validated username | |||
*/ | */ | |||
public function validateUser($user, $pass) | public function validateUser(?string $user, ?string $pass) | |||
{ | { | |||
return (phpCAS::isAuthenticated()) ? $user : false; | return (phpCAS::isAuthenticated()) ? $user : false; | |||
} | } | |||
public function getUser($username) | public function getUser(string $username) : ?User | |||
{ | { | |||
$user = new User($username); | $user = new User($username); | |||
$user->level = $this->getLevel($username); | $user->level = $this->getLevel($username); | |||
$user->email = $this->getDefaultEmail($username); | $user->email = $this->getDefaultEmail($username); | |||
return $user; | return $user; | |||
} | } | |||
private function getLevel($username) | private function getLevel(string $username) : int | |||
{ | { | |||
global $auth; | global $auth; | |||
// User not logged in, user level '0' | // User not logged in, user level '0' | |||
if (!isset($username)) | if (!isset($username)) | |||
{ | { | |||
return 0; | return 0; | |||
} | } | |||
// If the attribute filters are set, check to see whether the user has | // If the attribute filters are set, check to see whether the user has | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |