diff --git a/src/Tools/Authenticator.php b/src/Tools/Authenticator.php index 8fb182a..4c5a55c 100644 --- a/src/Tools/Authenticator.php +++ b/src/Tools/Authenticator.php @@ -135,7 +135,12 @@ public function getUser(){ * @return mixed Returns the primary key value if authenticated, null otherwise. */ public function getUserId(){ - return self::$user ? self::$user->getPrimary() : null; + if(!self::$user){ + $user = $this->getUser(); + if(!$user) return null; + } + + return self::$user->getPrimary(); } /** diff --git a/src/View/Skeltch.php b/src/View/Skeltch.php index e483909..261e21b 100644 --- a/src/View/Skeltch.php +++ b/src/View/Skeltch.php @@ -188,7 +188,7 @@ private static function compileLoops(string $code){ * @return string Returns the compiled code. */ private static function compileForEachs(string $code){ - return preg_replace_callback('~(? (.*?))?\)\s*}~is', function($matches){ + return preg_replace_callback('~(?\s+(.*?))?\)\s*}~is', function($matches){ if(isset($matches[4])){ return sprintf(' %s): $loop = \Glowie\Core\View\Skeltch::getLoop(%s); ?>', $matches[1], $matches[2], $matches[4], $matches[1]); }else{