From 40fc2f8c756b541e07bf72e004cef16b89814d96 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 27 Feb 2023 13:06:34 +0100 Subject: [PATCH] Auth\Cas: fix handling fake_authenticated_user --- src/Auth/Cas.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Auth/Cas.php b/src/Auth/Cas.php index 993eac3..07f695e 100644 --- a/src/Auth/Cas.php +++ b/src/Auth/Cas.php @@ -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;