Auth\Cas: fix handling fake_authenticated_user

This commit is contained in:
Benjamin Renard 2023-02-27 13:06:34 +01:00
parent 02b0bbcfad
commit 40fc2f8c75

View file

@ -81,16 +81,21 @@ class Cas extends Method {
* @return \EesyPHP\Auth\User|null
*/
public static function login($force=false) {
if (!phpCAS :: isAuthenticated() && $force) {
$_SESSION['cas_callback_url'] = self :: get_cas_callback_url();
phpCAS :: setFixedServiceURL($_SESSION['cas_callback_url']);
phpCAS :: forceAuthentication();
if (self :: $fake_authenticated_user) {
$user = Auth :: get_user(self :: $fake_authenticated_user);
}
else {
if (!phpCAS :: isAuthenticated() && $force) {
$_SESSION['cas_callback_url'] = self :: get_cas_callback_url();
phpCAS :: setFixedServiceURL($_SESSION['cas_callback_url']);
phpCAS :: forceAuthentication();
}
$user = (
phpCAS :: isAuthenticated()?
Auth :: get_user(phpCAS :: getUser()):
null
);
}
$user = (
phpCAS :: isAuthenticated()?
Auth :: get_user(phpCAS :: getUser()):
null
);
if ($force && !$user)
Log :: fatal('Fail to authenticate you');
return $user;