Example #1
0
 public function index()
 {
     if (Session::getActiveUserid() != null) {
         App::redirect(__ADMINPANE__ . '/mainside');
     }
     $form = new FormEngine\Elements\Form(array('name' => 'forgotlogin', 'action' => '', 'method' => 'post', 'class' => 'login-form'));
     $form->AddChild(new FormEngine\Elements\TextField(array('name' => 'login', 'label' => _('TXT_EMAIL_FORM_LOGIN'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_LOGIN_FORM_LOGIN'))))));
     $form->AddChild(new FormEngine\Elements\Submit(array('name' => 'log_in', 'label' => _('TXT_FORGOT_PASSWORD'))));
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\NoCode());
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         $loginValues = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT);
         $result = App::getModel('login')->checkUsers($loginValues['login']);
         if ($result == 0) {
             Session::setVolatileLoginError(1, false);
         } else {
             $password = Core::passwordGenerate();
             App::getModel('login')->changeUsersPassword($result, $password);
             $this->registry->template->assign('password', $password);
             App::getModel('mailer')->sendEmail(array('template' => 'forgotUsers', 'email' => array($_POST['login']), 'bcc' => false, 'subject' => _('TXT_FORGOT_PASSWORD'), 'viewid' => Helper::getViewId()));
             Session::setVolatileMessage("Nowe hasło zostało wysłane na podany adres e-mail.");
             App::redirect('login');
         }
     }
     $error = Session::getVolatileLoginError();
     if ($error[0] == 1) {
         $this->registry->template->assign('error', _('ERR_BAD_EMAIL'));
     }
     $languages = App::getModel('language')->getLanguages();
     $this->registry->xajax->processRequest();
     $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript());
     $this->registry->template->assign('form', $form->Render());
     $this->registry->template->assign('languages', json_encode($languages));
     $this->registry->template->display($this->loadTemplate('index.tpl'));
 }
Example #2
0
 public function index()
 {
     if (strlen($this->registry->core->getParam()) > 0) {
         $result = App::getModel('login')->authProccessSha($this->registry->core->getParam());
         if ($result == 1) {
             Session::setActiveLoginError(null);
             Session::setActiveUserid($result);
             App::getModel('login')->checkInstanceIsValid();
             App::getModel('login')->setLoginTime();
             App::getModel('login')->getUserData();
             App::getModel('login')->setDefaultView($result);
             App::redirect(__ADMINPANE__ . '/mainside');
         }
     }
     if (Session::getActiveUserid() != null) {
         App::redirect(__ADMINPANE__ . '/mainside');
     }
     $form = new FormEngine\Elements\Form(array('name' => 'login', 'action' => '', 'method' => 'post', 'class' => 'login-form', 'csrf' => false));
     $form->AddChild(new FormEngine\Elements\TextField(array('name' => 'login', 'label' => _('TXT_EMAIL_FORM_LOGIN'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_EMAIL_FORM_LOGIN'))))));
     $form->AddChild(new FormEngine\Elements\Password(array('name' => 'password', 'label' => _('TXT_LOGIN_FORM_PASSWORD'), 'rules' => array(new FormEngine\Rules\Required(_('ERR_EMPTY_LOGIN_FORM_PASSWORD'))))));
     $form->AddChild(new FormEngine\Elements\Checkbox(array('name' => 'autologin', 'label' => _('TXT_AUTOLOGIN'))));
     $form->AddChild(new FormEngine\Elements\Submit(array('name' => 'log_in', 'label' => _('TXT_LOG_IN'))));
     $form->AddChild(new FormEngine\Elements\StaticText(array('text' => '<a href="' . App::getURLAdress() . 'forgotlogin">' . _('TXT_LOGIN_FORM_RESET_PASSWORD') . '</a>')));
     $form->AddFilter(new FormEngine\Filters\Trim());
     $form->AddFilter(new FormEngine\Filters\NoCode());
     if ($form->Validate(FormEngine\FE::SubmittedData())) {
         $loginValues = $form->getSubmitValues(FormEngine\Elements\Form::FORMAT_FLAT);
         $result = App::getModel('login')->authProccess($loginValues['login'], $loginValues['password']);
         if ($result == 0) {
             Session::setVolatileLoginError(1, false);
         } else {
             if (isset($loginValues['autologin']) && $loginValues['autologin'] == 1) {
                 App::getModel('login')->setAdminAutologinKey($result);
             } else {
                 App::getModel('login')->destroyAdminAutologinKey();
             }
             Session::setActiveLoginError(null);
             Session::setActiveUserid($result);
             App::getModel('login')->checkInstanceIsValid();
             App::getModel('login')->setLoginTime();
             App::getModel('login')->getUserData();
             App::getModel('login')->setDefaultView($result);
             App::redirect(__ADMINPANE__ . '/mainside');
         }
     }
     $error = Session::getVolatileLoginError();
     if ($error[0] == 1) {
         $this->registry->template->assign('error', _('ERR_BAD_LOGIN_OR_PASSWORD'));
     }
     $languages = App::getModel('language')->getLanguages();
     $this->registry->xajax->processRequest();
     $this->registry->template->assign('xajax', $this->registry->xajax->getJavascript());
     $this->registry->template->assign('form', $form->Render());
     $this->registry->template->assign('languages', json_encode($languages));
     $this->registry->template->display($this->loadTemplate('index.tpl'));
 }