Exemplo n.º 1
0
 /**
  * Request new password for specified username
  * @service
  * @anonym
  *
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Form
  */
 public function requestNewPassword(Gpf_Rpc_Params $params)
 {
     $response = new Gpf_Rpc_Form($params);
     if (!Gpf_Captcha::isValid('lost_pw_captcha', $response->getFieldValue('lost_pw_captcha'))) {
         $response->setFieldError('lost_pw_captcha', $this->_("You have entered invalid security code"));
         return $response;
     }
     try {
         $user = new Gpf_Db_AuthUser();
         $user->setUsername($response->getFieldValue('username'));
         $user->loadFromData(array(Gpf_Db_Table_AuthUsers::USERNAME));
     } catch (Gpf_Exception $e) {
         $response->setFieldError('username', $this->_("You entered invalid username"));
         return $response;
     }
     $mail = new Gpf_Auth_RequestNewPasswordMail();
     $mail->setUser($user);
     $mail->setUrl($response->getFieldValue('applicationUrl'));
     $mail->addRecipient($user->getEmail());
     $mail->sendNow();
     $response->setInfoMessage($this->_("Within a few minutes you will receive instruction on how to reset you password."));
     return $response;
 }
Exemplo n.º 2
0
    /**
     * @service affiliate write
     * @return Gpf_Rpc_Action
     */
    public function sendRequestPassword(Gpf_Rpc_Params $params) {
        $action = new Gpf_Rpc_Action($params, $this->_('New password request email successfully sent'), $this->_('Failed to send new password request email'));

        foreach ($action->getIds() as $id) {
            try {
                $affiliate = $this->loadUserFromId($id);
                if ($affiliate->getStatus() == Pap_Common_Constants::STATUS_APPROVED) {
                    $user = $affiliate->getAuthUser();
                    $mail = new Gpf_Auth_RequestNewPasswordMail();
                    $mail->setUser($user);
                    $mail->setUrl(Gpf_Paths::getInstance()->getFullBaseServerUrl() . "affiliates/login.php");
                    $this->sendMail($user, $mail);
                    $action->addOk();
                } else {
                    $action->addError();
                }
            } catch (Exception $e) {
                $action->addError();
            }
        }

        return $action;
    }