/**
  * Activate an account
  */
 protected function activateAcount()
 {
     $hasError = false;
     $strReloadUrl = preg_replace('/(&|\\?)token=[^&]*/', '', \Environment::get('request'));
     // remove token from url
     $objMember = \MemberModel::findByActivation(MEMBER_ACTIVATION_ACTIVATED_FIELD_PREFIX . \Input::get('token'));
     // member with this token already activated
     if ($objMember !== null) {
         $hasError = true;
         MemberMessage::addDanger($GLOBALS['TL_LANG']['MSC']['alreadyActivated']);
     }
     // check for invalid token
     if (!$hasError) {
         $objMember = \MemberModel::findByActivation(\Input::get('token'));
         if ($objMember === null) {
             $hasError = true;
             MemberMessage::addDanger($GLOBALS['TL_LANG']['MSC']['invalidActivationToken']);
         }
     }
     // if has errors, remove token from url and redirect to current page without token parameter
     if ($hasError) {
         $this->redirect($strReloadUrl);
     }
     // Update the account
     $objMember->disable = '';
     $objMember->activation = MEMBER_ACTIVATION_ACTIVATED_FIELD_PREFIX . $objMember->activation;
     $objMember->save();
     $this->accountActivatedMessage = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objMember, $this);
         }
     }
     // Log activity
     $this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
     // Redirect to the jumpTo page
     if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     } else {
         MemberMessage::addSuccess($this->accountActivatedMessage);
         $this->redirect($strReloadUrl);
     }
 }
Exemplo n.º 2
0
 /**
  * Set the new password
  */
 protected function setNewPassword()
 {
     $objMember = \MemberModel::findByActivation(\Input::get('token'));
     if ($objMember === null || $objMember->login == '') {
         $this->strTemplate = 'mod_message';
         $this->Template = new \FrontendTemplate($this->strTemplate);
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     // Define the form field
     $arrField = $GLOBALS['TL_DCA']['tl_member']['fields']['password'];
     $arrField['eval']['tableless'] = $this->tableless;
     $strClass = $GLOBALS['TL_FFL']['password'];
     // Fallback to default if the class is not defined
     if (!class_exists($strClass)) {
         $strClass = 'FormPassword';
     }
     $objWidget = new $strClass($strClass::getAttributesFromDca($arrField, 'password'));
     // Set row classes
     $objWidget->rowClass = 'row_0 row_first even';
     $objWidget->rowClassConfirm = 'row_1 odd';
     $this->Template->rowLast = 'row_2 row_last even';
     // Validate the field
     if (strlen(\Input::post('FORM_SUBMIT')) && \Input::post('FORM_SUBMIT') == $this->Session->get('setPasswordToken')) {
         $objWidget->validate();
         // Set the new password and redirect
         if (!$objWidget->hasErrors()) {
             $this->Session->set('setPasswordToken', '');
             array_pop($_SESSION['TL_CONFIRM']);
             $objMember->activation = '';
             $objMember->password = $objWidget->value;
             $objMember->save();
             // HOOK: set new password callback
             if (isset($GLOBALS['TL_HOOKS']['setNewPassword']) && is_array($GLOBALS['TL_HOOKS']['setNewPassword'])) {
                 foreach ($GLOBALS['TL_HOOKS']['setNewPassword'] as $callback) {
                     $this->import($callback[0]);
                     $this->{$callback}[0]->{$callback}[1]($objMember, $objWidget->value, $this);
                 }
             }
             // Redirect to the jumpTo page
             if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
                 $this->redirect($this->generateFrontendUrl($objTarget->row()));
             }
             // Confirm
             $this->strTemplate = 'mod_message';
             $this->Template = new \FrontendTemplate($this->strTemplate);
             $this->Template->type = 'confirm';
             $this->Template->message = $GLOBALS['TL_LANG']['MSC']['newPasswordSet'];
             return;
         }
     }
     $strToken = md5(uniqid(mt_rand(), true));
     $this->Session->set('setPasswordToken', $strToken);
     $this->Template->formId = $strToken;
     $this->Template->fields = $objWidget->parse();
     $this->Template->action = \Environment::get('indexFreeRequest');
     $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['setNewPassword']);
     $this->Template->tableless = $this->tableless;
 }
Exemplo n.º 3
0
 /**
  * Activate an account
  */
 protected function activateAcount()
 {
     $this->strTemplate = 'mod_message';
     $this->Template = new \FrontendTemplate($this->strTemplate);
     // Check the token
     $objMember = \MemberModel::findByActivation(\Input::get('token'));
     if ($objMember === null) {
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     // Update the account
     $objMember->disable = '';
     $objMember->activation = '';
     $objMember->save();
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objMember, $this);
         }
     }
     $arrData = array();
     // Get the editable fields
     foreach ($this->editable as $key) {
         $arrData[$key] = $objMember->{$key};
     }
     // Add the login details
     $arrData['login'] = $objMember->login;
     $arrData['groups'] = $objMember->groups;
     $arrData['disable'] = '';
     // Log activity
     $this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', 'ModuleRegistration activateAccount()', TL_ACCESS);
     // Redirect to the jumpTo page
     if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
     // Confirm activation
     $this->Template->type = 'confirm';
     $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
 }
Exemplo n.º 4
0
 /**
  * Activate an account
  */
 protected function activateAcount()
 {
     $this->strTemplate = 'mod_message';
     /** @var \FrontendTemplate|object $objTemplate */
     $objTemplate = new \FrontendTemplate($this->strTemplate);
     $this->Template = $objTemplate;
     $objMember = \MemberModel::findByActivation(\Input::get('token'));
     if ($objMember === null) {
         $this->Template->type = 'error';
         $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     // Update the account
     $objMember->disable = '';
     $objMember->activation = '';
     $objMember->save();
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objMember, $this);
         }
     }
     // Log activity
     $this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
     // Redirect to the jumpTo page
     if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
     // Confirm activation
     $this->Template->type = 'confirm';
     $this->Template->message = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
 }
 /**
  * Activate an account
  */
 protected function activateAcount()
 {
     // Check the token
     $objMember = \MemberModel::findByActivation(\Input::get('token'));
     if ($objMember === null) {
         $_SESSION['LOGIN_ERROR'] = $GLOBALS['TL_LANG']['MSC']['accountError'];
         return;
     }
     // Update the account
     $objMember->disable = '';
     $objMember->activation = '';
     $objMember->save();
     // Log activity
     $this->log('User account ID ' . $objMember->id . ' (' . $objMember->email . ') has been activated', __METHOD__, TL_ACCESS);
     // Confirm activation
     $_SESSION['LOGIN_SUCCESS'] = $GLOBALS['TL_LANG']['MSC']['accountActivated'];
     // HOOK: post activation callback
     if (isset($GLOBALS['TL_HOOKS']['activateAccount']) && is_array($GLOBALS['TL_HOOKS']['activateAccount'])) {
         foreach ($GLOBALS['TL_HOOKS']['activateAccount'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($objMember, $this);
         }
     }
     // Redirect to the jumpTo page
     if (($objTarget = $this->objModel->getRelated('reg_jumpTo')) !== null) {
         $this->redirect($this->generateFrontendUrl($objTarget->row()));
     }
 }