private function getPasswordRequest() { Gpf_Db_Table_PasswordRequests::invalidateOtherRequest($this->user->getId()); $passwordRequest = new Gpf_Db_PasswordRequest(); $passwordRequest->setAuthUser($this->user->getId()); $passwordRequest->insert(); return $passwordRequest; }
public function save() { if ($this->isFirstChangeStatus()) { $this->setDateApproved(Gpf_Common_DateUtils::now()); } try { $authUser = new Gpf_Db_AuthUser(); $authUser->setPrimaryKeyValue($this->authUser->getPrimaryKeyValue()); $authUser->load(); $this->accountUser->setAuthId($authUser->getId()); } catch (Gpf_Exception $e) { try { $this->authUser->loadFromUsername(); $this->accountUser->setAuthId($this->authUser->getId()); } catch (Exception $e) { } } $this->inserting = !$this->user->rowExists(); $this->checkConstraints(); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.beforeSave', $this); $this->authUser->save(); $this->accountUser->setAuthId($this->authUser->getId()); try { $this->accountUser->save(); } catch (Gpf_Exception $e) { $this->authUser->delete(); throw new Gpf_Exception($e->getMessage()); } $this->user->set('accountuserid', $this->accountUser->get('accountuserid')); $this->initRefid($this->accountUser->getId()); $this->initMinimupPayout(); try { $this->user->save(); } catch (Gpf_Exception $e) { $this->authUser->delete(); $this->accountUser->delete(); throw new Gpf_Exception($e->getMessage()); } if ($this->inserting) { $this->afterInsert(); } else { Pap_Db_Table_CachedBanners::deleteCachedBannersForUser($this->user->getId(), $this->user->getRefId()); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.afterSave', $this); } }
/** * @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; }
/** * 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; }