/** * @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]; }