Example #1
0
 /**
  * @inheritdoc
  */
 public function authenticate()
 {
     $userData = 0;
     if ($this->sessionHandler->has(AuthenticationModel::AUTH_NAME)) {
         $userData = $this->sessionHandler->get(AuthenticationModel::AUTH_NAME, []);
     } elseif ($this->request->getCookies()->has(AuthenticationModel::AUTH_NAME)) {
         list($userId, $token) = explode('|', $this->request->getCookies()->get(AuthenticationModel::AUTH_NAME, ''));
         $userData = $this->verifyCredentials($userId, $token);
     }
     $this->authenticationModel->authenticate($userData);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function destroy($sessionId)
 {
     $this->secureSession();
     if ($this->request->getCookies()->has(self::SESSION_NAME)) {
         $cookie = new Cookie(self::SESSION_NAME, '', (new \DateTime())->modify('-3600 seconds'), $this->appPath->getWebRoot(), null, $this->request->getSymfonyRequest()->isSecure());
         $this->response->headers->setCookie($cookie);
     }
     // Delete the session from the database
     $this->db->getConnection()->delete($this->db->getPrefix() . 'sessions', ['session_id' => $sessionId]);
     return true;
 }
Example #3
0
 private function setLanguage()
 {
     $cookieLocale = $this->request->getCookies()->get('ACP3_INSTALLER_LANG', '');
     if (!preg_match('=/=', $cookieLocale) && is_file($this->appPath->getInstallerModulesDir() . 'Install/Resources/i18n/' . $cookieLocale . '.xml') === true) {
         $language = $cookieLocale;
     } else {
         $language = 'en_US';
         // Fallback language
         foreach ($this->request->getUserAgent()->parseAcceptLanguage() as $locale => $val) {
             $locale = str_replace('-', '_', $locale);
             if ($this->translator->languagePackExists($locale) === true) {
                 $language = $locale;
                 break;
             }
         }
     }
     $this->translator->setLocale($language);
 }