Esempio n. 1
0
 /**
  * @param $reason
  */
 protected function _userConfirm($reason)
 {
     if (!Pii::guest()) {
         $this->redirect('/');
     }
     $_model = new ConfirmUserForm();
     // collect user input data
     if (isset($_POST, $_POST['ConfirmUserForm'])) {
         $_model->attributes = $_POST['ConfirmUserForm'];
         //	Validate user input and redirect to the previous page if valid
         if ($_model->validate()) {
             try {
                 switch ($reason) {
                     case 'register':
                         $_result = Register::userConfirm($_model->email, $_model->code, $_model->password, true, false);
                         break;
                     default:
                         $_result = Password::changePasswordByCode($_model->email, $_model->code, $_model->password, true, false);
                         break;
                 }
                 if ($_result) {
                     $this->redirect($this->_getRedirectUrl());
                     return;
                 }
                 $_model->addError(null, 'Password changed successfully, but failed to automatically login.');
             } catch (\Exception $_ex) {
                 $_model->addError('email', $_ex->getMessage());
             }
         }
     }
     $this->render('confirm', array('model' => $_model, 'reason' => $reason));
 }