protected function setVariableValues()
 {
     $this->setVariable('username', $this->user->getUsername());
     $this->setVariable('firstname', $this->user->getFirstName());
     $this->setVariable('lastname', $this->user->getLastName());
     $this->setVariable('newPasswordUrl', $this->url);
     $this->setVariable('newPasswordLink', '<a href="' . $this->fullUrl . '">' . Gpf_Lang::_('To reset your password click here', null, $this->getRecipientLanguage()) . '</a>');
     $this->addRecipient($this->user->getEmail());
 }
Example #2
0
 protected function beforeSaveCheck() {
     try {
         parent::beforeSaveCheck();
     } catch (Gpf_DbEngine_Row_PasswordConstraintException $e) {
         if(!$this->isMasterMerchant($this->get(Gpf_Db_Table_AuthUsers::ID))) {
             throw $e;
         }
     }
 }
Example #3
0
 /**
  * Update last known IP address of logged in user
  *
  * @param $ip New ip address
  */
 public function updateIp($ip)
 {
     $this->ip = $ip;
     try {
         //update last known ip address of user in auth user row
         $dbAuthUser = new Gpf_Db_AuthUser();
         $dbAuthUser->setId($this->getAuthUserId());
         $dbAuthUser->updateIp($ip);
     } catch (Gpf_Exception $e) {
     }
 }
Example #4
0
 /**
  * @return Gpf_Db_AuthUser
  */
 protected function createUserWithUserName()
 {
     $authUser = new Gpf_Db_AuthUser();
     $authUser->setUsername($this->getUsername());
     return $authUser;
 }
Example #5
0
 /**
  * @return array {key == lang code, value == array {key == timeOffset, value == array of recipients}}
  */
 private function getRecipients()
 {
     $recipients = array();
     $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator();
     foreach ($this->recipients as $email => $recipient) {
         if (!$emailValidator->validate($email)) {
             Gpf_Log::warning('Email will not be sent to the address "' . $email . '". Address is not valid.');
             continue;
         }
         try {
             $authuser = new Gpf_Db_AuthUser();
             $authuser->setNotificationEmail($email);
             $authuser->loadFromData(array(Gpf_Db_Table_AuthUsers::NOTIFICATION_EMAIL));
             $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId()));
         } catch (Gpf_Exception $e) {
             try {
                 $authuser->setUsername($email);
                 $authuser->loadFromUsername();
                 $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId()));
             } catch (Gpf_DbEngine_NoRowException $e) {
                 $recipients = $this->insertRecipient($recipients, $recipient);
             }
         }
     }
     return $recipients;
 }
 private function sendMail(Gpf_Db_AuthUser $user, Gpf_Mail_Template $mail) {
     $userMail = clone $mail;
     $userMail->addRecipient($user->getEmail());
     $userMail->sendNow();
 }
Example #7
0
 public function setEmail($email) {
     $this->authUser->setEmail($email);
 }
 private function addRecipientsFilter(Gpf_SqlBuilder_Filter $filter)
 {
     $condition = new Gpf_SqlBuilder_CompoundWhereCondition();
     $condition->add('m.' . Gpf_Db_Table_Mails::TO_RECIPIENTS, '=', $filter->getValue(), 'OR');
     try {
         $dbUser = new Gpf_Db_AuthUser();
         $dbUser->setUsername($filter->getValue());
         $dbUser->loadFromData(array(Gpf_Db_Table_AuthUsers::USERNAME));
         if (strlen($dbUser->getNotificationEmail())) {
             $condition->add('m.' . Gpf_Db_Table_Mails::TO_RECIPIENTS, '=', $dbUser->getNotificationEmail(), 'OR');
         }
     } catch (Exception $e) {
     }
     $this->_selectBuilder->where->addCondition($condition);
 }
Example #9
0
 /**
  * Set new password for user, which requested new password
  *
  * @service
  * @anonym
  * @param Gfp_Rpc_Params $params
  * @return Gpf_Rpc_Form
  */
 public function setNewPassword(Gpf_Rpc_Params $params)
 {
     $response = new Gpf_Rpc_Form($params);
     if (!Gpf_Captcha::isValid('set_pw_captcha', $response->getFieldValue('set_pw_captcha'))) {
         $response->setFieldError('set_pw_captcha', $this->_("You entered invalid security code"));
         return $response;
     }
     Gpf_Db_Table_PasswordRequests::expireOldRequest();
     $errorMessageInvalidUsername = $this->_('You entered invalid username');
     $user = new Gpf_Db_AuthUser();
     $user->setUsername($response->getFieldValue('username'));
     try {
         $user->loadFromData(array(Gpf_Db_Table_AuthUsers::USERNAME));
     } catch (Gpf_Exception $e) {
         $response->setFieldError('username', $errorMessageInvalidUsername);
         return $response;
     }
     $errorMessage = $this->getInvalidPasswordRequestErrorMessage();
     $passwordRequest = new Gpf_Db_PasswordRequest();
     $passwordRequest->setId($response->getFieldValue('requestid'));
     try {
         $passwordRequest->load();
     } catch (Gpf_Exception $e) {
         $response->setErrorMessage($errorMessage);
         return $response;
     }
     if ($user->getId() != $passwordRequest->getAuthUser()) {
         $response->setFieldError('username', $errorMessageInvalidUsername);
         return $response;
     }
     if ($passwordRequest->getStatus() != Gpf_Db_Table_PasswordRequests::STATUS_PENDING || $user->getUsername() != $response->getFieldValue('username')) {
         $response->setErrorMessage($errorMessage);
         return $response;
     }
     $user->setPassword($response->getFieldValue('password'));
     try {
         $user->update(array(Gpf_Db_Table_AuthUsers::PASSWORD));
     } catch (Gpf_DbEngine_Row_ConstraintException $e) {
         $response->setErrorMessage($e->getMessage());
         return $response;
     }
     $passwordRequest->setStatus(Gpf_Db_Table_PasswordRequests::STATUS_APPLIED);
     $passwordRequest->update(array(Gpf_Db_Table_PasswordRequests::STATUS));
     $response->setInfoMessage($this->_("Your password was changed. Go back to login dialog and login."));
     return $response;
 }