/** * Authenticates the user * * @param void * @return mixed {Zend\Http\PhpEnvironment\Response, ViewModel} **/ public function loginAction() { $params = array('controller' => 'blog', 'action' => 'view-all'); if ($this->_userService->getAuthService()->hasIdentity()) { return $this->redirect()->toRoute('blog/default', $params); } $request = $this->getRequest(); if ($request->isPost()) { if ($this->_userService->auth($request->getPost())) { return $this->redirect()->toRoute('blog/default', $params); } } return new ViewModel(array('form' => $this->_userService->getForm(), 'messages' => $this->_userService->getMessages(UserService::MSG_NOTICE), 'errors' => $this->_userService->getMessages(UserService::MSG_ERROR))); }