예제 #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);
 }
예제 #2
0
 /**
  * @param string $last
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function execute($last = '')
 {
     $this->authenticationModel->logout();
     if (!empty($last)) {
         $lastPage = base64_decode($last);
         if (!preg_match('/^((acp|users)\\/)/', $lastPage)) {
             return $this->redirect()->temporary($lastPage);
         }
     }
     return $this->redirect()->toNewPage($this->appPath->getWebRoot());
 }
예제 #3
0
파일: Edit.php 프로젝트: acp3/module-users
 /**
  * @param int $userId
  */
 protected function updateCurrentlyLoggedInUserCookie($userId)
 {
     if ($userId == $this->user->getUserId() && $this->request->getCookies()->has(Users\Model\AuthenticationModel::AUTH_NAME)) {
         $user = $this->usersModel->getOneById($userId);
         $cookie = $this->authenticationModel->setRememberMeCookie($userId, $user['remember_me_token']);
         $this->response->headers->setCookie($cookie);
     }
 }
예제 #4
0
파일: Login.php 프로젝트: acp3/module-users
 /**
  * @return array|JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost()
 {
     try {
         $this->authenticationModel->login($this->get('core.helpers.secure')->strEncode($this->request->getPost()->get('nickname', '')), $this->request->getPost()->get('pwd', ''), $this->request->getPost()->has('remember'));
         if ($this->request->getParameters()->has('redirect')) {
             return $this->redirect()->temporary(base64_decode($this->request->getParameters()->get('redirect')));
         }
         return $this->redirect()->toNewPage($this->appPath->getWebRoot());
     } catch (Users\Exception\LoginFailedException $e) {
         $errorPhrase = 'nickname_or_password_wrong';
     } catch (Users\Exception\UserAccountLockedException $e) {
         $errorPhrase = 'account_locked';
     }
     $errors = $this->get('core.helpers.alerts')->errorBox($this->translator->t('users', $errorPhrase));
     if ($this->request->isXmlHttpRequest()) {
         return new JsonResponse(['success' => false, 'content' => $errors]);
     }
     return ['error_msg' => $errors];
 }
예제 #5
0
 /**
  * @param array $formData
  * @param array $settings
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings)
 {
     return $this->actionHelper->handlePostAction(function () use($formData, $settings) {
         $this->accountSettingsFormValidation->setSettings($settings)->validate($formData);
         $formData['time_zone'] = $formData['date_time_zone'];
         if ($settings['language_override'] == 0) {
             unset($formData['language']);
         }
         if (!empty($formData['new_pwd']) && !empty($formData['new_pwd_repeat'])) {
             $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
             $newPassword = $this->secureHelper->generateSaltedPassword($salt, $formData['new_pwd'], 'sha512');
             $formData['pwd'] = $newPassword;
             $formData['pwd_salt'] = $salt;
         }
         $bool = $this->usersModel->save($formData, $this->user->getUserId());
         $user = $this->usersModel->getOneById($this->user->getUserId());
         $cookie = $this->authenticationModel->setRememberMeCookie($this->user->getUserId(), $user['remember_me_token']);
         $this->response->headers->setCookie($cookie);
         return $this->redirectMessages()->setMessage($bool, $this->translator->t('system', $bool !== false ? 'settings_success' : 'settings_error'));
     });
 }