Skip to content
Snippets Groups Projects
Commit a7e427a3 authored by Bart Visscher's avatar Bart Visscher
Browse files

Remember result of OC_User::isLoggedIn, can be very expensive to check

parent 8aa7ed39
No related branches found
No related tags found
No related merge requests found
...@@ -240,13 +240,17 @@ class OC_User { ...@@ -240,13 +240,17 @@ class OC_User {
* Checks if the user is logged in * Checks if the user is logged in
*/ */
public static function isLoggedIn(){ public static function isLoggedIn(){
static $is_login_checked = null;
if (!is_null($is_login_checked)) {
return $is_login_checked;
}
if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) { if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
OC_App::loadApps(array('authentication')); OC_App::loadApps(array('authentication'));
if (self::userExists($_SESSION['user_id']) ){ if (self::userExists($_SESSION['user_id']) ){
return true; return $is_login_checked = true;
} }
} }
return false; return $is_login_checked = false;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment