/**
  * It will render form after user signup
  *
  */
 public function indexAction()
 {
     $registerHash = $this->request->getQuery('registerhash');
     if (empty($registerHash)) {
         $this->flashSession->error('Hack attempt!!!');
         return $this->response->redirect('/');
     }
     if ($this->auth->getAuth()) {
         $this->view->disable();
         return $this->response->redirect();
     }
     $object = Users::findFirstByRegisterHash($registerHash);
     if (!$object) {
         $this->flashSession->error('Invalid data.');
         return $this->response->redirect();
     }
     $form = new ResetPasswordForm();
     $this->view->form = $form;
     if ($this->request->isPost()) {
         if (!$form->isValid($_POST)) {
             foreach ($form->getMessages() as $message) {
                 $this->flashSession->error($message);
             }
         } else {
             $password = $this->request->getPost('password_new_confirm');
             $object->setPasswd($this->security->hash($password));
             $object->setRegisterHash(null);
             $object->setStatus(Users::STATUS_ACTIVE);
             if (!$object->save()) {
                 $this->displayModelErrors($object);
             } else {
                 $this->flashSession->success(t('Your password was changed successfully.'));
                 //Assign to session
                 $this->auth->check(['email' => $object->getEmail(), 'password' => $password, 'remember' => true]);
                 return $this->response->redirect();
             }
         }
     }
     $this->view->pick('register/resetpassword');
 }
 /**
  * registerAction function.
  *
  * @access public
  * @return void
  */
 public function registerAction()
 {
     if (empty($this->router->getParams()[0])) {
         $this->flashSession->error('Hack attempt!!!');
         return $this->response->redirect('/');
     }
     if ($this->auth->getAuth()) {
         $this->view->disable();
         return $this->response->redirect();
     }
     $registerHash = $this->router->getParams()[0];
     $object = Users::findFirstByRegisterHash($registerHash);
     if (!$object) {
         $this->flashSession->error('Invalid data.');
         return $this->response->redirect();
     }
     $form = new ResetPasswordForm();
     $this->view->form = $form;
     if ($this->request->isPost()) {
         if (!$form->isValid($_POST)) {
             foreach ($form->getMessages() as $message) {
                 $this->flashSession->error($message);
             }
         } else {
             $object->setPasswd($this->security->hash($this->request->getPost('password_new_confirm')));
             $object->setRegisterHash(null);
             $object->setStatus(Users::STATUS_ACTIVE);
             if (!$object->save()) {
                 $this->displayModelErrors($object);
             } else {
                 $this->flashSession->success(t('Your password was changed successfully.'));
                 return $this->response->redirect();
             }
         }
     }
     $this->view->pick(['auth/resetpassword']);
 }