private function authenticate() { $username = $this->input->server('PHP_AUTH_USER'); $password = $this->input->server('PHP_AUTH_PW'); if (isset($username) === FALSE || isset($password) === FALSE) { header('WWW-Authenticate: Basic realm="' . Kohana::config('config.site_domain') . '"'); $this->AutenticationFailed(); exit; } else { $user = new User_Model(); $user->email_address = $username; $user->password = $password; $result = $user->authenticate(); // No user found, send 403 if ($result == FALSE) { $this->AutenticationFailed(); } if (!$user->retrieveFromDB()) { $this->AutenticationFailed(); } $result = $user; // Store username and password to instance properties $username = $result->email_address; $password = $result->password; return $result; } }