Ejemplo n.º 1
0
 /**
  * @return \Phalcon\Http\ResponseInterface
  */
 public function indexAction()
 {
     $this->session->set('urlCurrent', $this->request->getHTTPReferer());
     if ($this->auth->getAuth()) {
         $this->view->disable();
         return $this->response->redirect();
     }
     $form = new LoginForm();
     try {
         if ($this->request->isPost()) {
             if (!$form->isValid($this->request->getPost())) {
                 foreach ($form->getMessages() as $message) {
                     $this->flashSession->error($message->getMessage());
                 }
             } else {
                 $this->auth->check(['email' => $this->request->getPost('email'), 'password' => $this->request->getPost('password'), 'remember' => true]);
             }
         }
     } catch (\Exception $e) {
         $this->flashSession->error($e->getMessage());
     }
     $this->view->loginForm = $form;
     $this->view->signupForm = new SignupForm();
 }
Ejemplo n.º 2
0
 /**
  * @return \Phalcon\Http\ResponseInterface
  */
 public function indexAction()
 {
     $url = $this->request->getHTTPReferer();
     if (empty($url)) {
         $url = ($this->request->isSecure() ? 'https://' : 'http://') . $this->request->getHttpHost() . '/oauth/login';
     }
     $this->cookies->set('HTTPBACK', serialize($url));
     if ($this->auth->getAuth()) {
         $this->view->disable();
         return $this->response->redirect();
     }
     $form = new LoginForm();
     if ($this->request->isPost()) {
         if (!$form->isValid($this->request->getPost())) {
             foreach ($form->getMessages() as $message) {
                 $this->flashSession->error($message->getMessage());
             }
         }
         $check = $this->auth->check(['email' => $this->request->getPost('email'), 'password' => $this->request->getPost('password'), 'remember' => true]);
         if ($check) {
             $this->flashSession->success(t('Welcome back ' . $this->auth->getName()));
         }
         return $this->currentRedirect();
     }
     $this->view->form = $form;
 }