Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     BackendAuthentication::logout();
     // redirect to login-screen
     $this->redirect(BackendModel::createUrlForAction('Index', $this->getModule()));
 }
Example #2
0
 private function redirectToAllowedModuleAndAction()
 {
     $allowedModule = $this->getAllowedModule();
     $allowedAction = $this->getAllowedAction($allowedModule);
     $allowedModuleActionUrl = $allowedModule ? BackendModel::createUrlForAction($allowedAction, $allowedModule) : BackendModel::createUrlForAction('Index', 'Authentication');
     $userEmail = BackendAuthentication::getUser()->getEmail();
     $this->getContainer()->get('logger')->info("Redirecting user '{$userEmail}' to {$allowedModuleActionUrl}.");
     $this->redirect($this->getParameter('querystring', 'string', $allowedModuleActionUrl));
 }
Example #3
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         // shorten fields
         $newPassword = $this->frm->getField('backend_new_password');
         $newPasswordRepeated = $this->frm->getField('backend_new_password_repeated');
         // required fields
         $newPassword->isFilled(BL::err('PasswordIsRequired'));
         $newPasswordRepeated->isFilled(BL::err('PasswordRepeatIsRequired'));
         // all fields are ok?
         if ($newPassword->isFilled() && $newPasswordRepeated->isFilled()) {
             // the passwords entered match
             if ($newPassword->getValue() !== $newPasswordRepeated->getValue()) {
                 // add error
                 $this->frm->addError(BL::err('PasswordsDontMatch'));
                 // show error
                 $this->tpl->assign('error', BL::err('PasswordsDontMatch'));
             }
         }
         if ($this->frm->isCorrect()) {
             // change the users password
             BackendUsersModel::updatePassword($this->user, $newPassword->getValue());
             // attempt to login the user
             if (!BackendAuthentication::loginUser($this->user->getEmail(), $newPassword->getValue())) {
                 // redirect to the login form with an error
                 $this->redirect(BackendModel::createURLForAction('Index', null, null, array('login' => 'failed')));
             }
             // redirect to the login form
             $this->redirect(BackendModel::createUrlForAction('Index', 'Dashboard', null, array('password_reset' => 'success')));
         }
     }
 }