/**
  * Login form
  */
 public function loginAction()
 {
     if ($this->zfcUserAuthentication()->hasIdentity()) {
         return $this->redirect()->toRoute($this->options->getLoginRedirectRoute());
     }
     $request = $this->getRequest();
     $post = $request->getPost();
     $form = $this->loginForm;
     $fm = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages();
     if (isset($fm[0])) {
         $this->loginForm->setMessages(array('identity' => array($fm[0])));
     }
     if ($this->options->getUseRedirectParameterIfPresent()) {
         $redirect = $request->getQuery()->get('redirect', !empty($post['redirect']) ? $post['redirect'] : false);
     } else {
         $redirect = false;
     }
     if (!$request->isPost()) {
         return array('loginForm' => $form, 'redirect' => $redirect, 'enableRegistration' => $this->options->getEnableRegistration());
     }
     $form->setData($post);
     if (!$form->isValid()) {
         $this->flashMessenger()->setNamespace('zfcuser-login-form')->addMessage($this->failedLoginMessage);
         return $this->redirect()->toUrl($this->url()->fromRoute(static::ROUTE_LOGIN) . ($redirect ? '?redirect=' . rawurlencode($redirect) : ''));
     }
     // clear adapters
     $this->zfcUserAuthentication()->getAuthAdapter()->resetAdapters();
     $this->zfcUserAuthentication()->getAuthService()->clearIdentity();
     return $this->forward()->dispatch(static::CONTROLLER_NAME, array('action' => 'authenticate'));
 }
Example #2
0
 public function setLoginForm(Form $loginForm)
 {
     $this->loginForm = $loginForm;
     $fm = $this->flashMessenger()->setNamespace('zfcuser-login-form')->getMessages();
     if (isset($fm[0])) {
         $this->loginForm->setMessages(array('identity' => array($fm[0])));
     }
     return $this;
 }
 /**
  * @param Form $loginForm
  * @return $this
  */
 public function setLoginForm(Form $loginForm)
 {
     $this->loginForm = $loginForm;
     $fm = $this->flashMessenger()->getMessages();
     if (isset($fm[0])) {
         $this->loginForm->setMessages(['identity' => [$fm[0]]]);
     }
     return $this;
 }