diff options
Diffstat (limited to 'app/Model/Authentication.php')
-rw-r--r-- | app/Model/Authentication.php | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/app/Model/Authentication.php b/app/Model/Authentication.php index b9ebcfe2..86c1c43f 100644 --- a/app/Model/Authentication.php +++ b/app/Model/Authentication.php @@ -3,7 +3,6 @@ namespace Model; use Core\Request; -use Auth\Database; use SimpleValidator\Validator; use SimpleValidator\Validators; @@ -24,31 +23,31 @@ class Authentication extends Base */ public function backend($name) { - if (! isset($this->registry->$name)) { + if (! isset($this->container[$name])) { $class = '\Auth\\'.ucfirst($name); - $this->registry->$name = new $class($this->registry); + $this->container[$name] = new $class($this->container); } - return $this->registry->shared($name); + return $this->container[$name]; } /** * Check if the current user is authenticated * * @access public - * @param string $controller Controller - * @param string $action Action name * @return bool */ - public function isAuthenticated($controller, $action) + public function isAuthenticated() { - // If the action is public we don't need to do any checks - if ($this->acl->isPublicAction($controller, $action)) { - return true; - } - // If the user is already logged it's ok - if ($this->acl->isLogged()) { + if ($this->userSession->isLogged()) { + + // Check if the user session match an existing user + if (! $this->user->exists($this->userSession->getId())) { + $this->backend('rememberMe')->destroy($this->userSession->getId()); + $this->session->close(); + return false; + } // We update each time the RememberMe cookie tokens if ($this->backend('rememberMe')->hasCookie()) { @@ -118,7 +117,7 @@ class Authentication extends Base if (! empty($values['remember_me'])) { $credentials = $this->backend('rememberMe') - ->create($this->acl->getUserId(), Request::getIpAddress(), Request::getUserAgent()); + ->create($this->userSession->getId(), Request::getIpAddress(), Request::getUserAgent()); $this->backend('rememberMe')->writeCookie($credentials['token'], $credentials['sequence'], $credentials['expiration']); } |