Closed adispartadev closed 6 years ago
Hi,
GetCurrentUser is just a wrapper for Cas::getUser(). I've checked the phpCas rapidly and I don't think it's possible to just catch an exception and return null, but maybe you should still try it. Something like this:
try {
$user = \Cas::getCurrentUser();
} catch(\Exception $e) {
$user = null;
}
It may not work as I'm not sure the phpCas library is actually throwing an error or not, but it's worth trying.
Xavier
Hi, thanks for your fast respon btw. I had try that and that not work.
try {
$user = \Cas::getCurrentUser();
} catch(\Exception $e) {
$user = null;
}
But it give an error Error: Internal script failure
. I try to add \Cas::authenticate();
before $user = \Cas::getCurrentUser();
but it redirect to our login page instead of return null.
I solved this problem by using this function to return true or false when user is login or not without redirect to sso page when user not login yet.
$isLogin = Cas::isAuthenticated();
I use
\Cas::authenticate();
and then$user = \Cas::getCurrentUser();
to get current login user as well. But, I want to getnull
when user not auth yet without redirect to CAS_LOGIN_REDIRECT.How can I do that?