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;