Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function AjaxAccountChangeForgotPassword()
 {
     $sEmail = trim((string) $this->getParamValue('Email', ''));
     $sQuestion = trim((string) $this->getParamValue('Question', ''));
     $sAnswer = trim((string) $this->getParamValue('Answer', ''));
     $sPassword = trim((string) $this->getParamValue('Password', ''));
     $oSettings =& \CApi::GetSettings();
     if (!$oSettings || !$oSettings->GetConf('Common/AllowPasswordReset') || 0 === strlen($sEmail) || 0 === strlen($sAnswer) || 0 === strlen($sQuestion) || 0 === strlen($sPassword)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
     }
     $oAccount = $this->oApiUsers->getAccountByEmail($sEmail);
     if (!$oAccount instanceof \CAccount || !$oAccount->IsInternal || $oAccount->User->Question1 !== $sQuestion || $oAccount->User->Answer1 !== $sAnswer) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
         // TODO
     }
     $oAccount->PreviousMailPassword = $oAccount->IncomingMailPassword;
     $oAccount->IncomingMailPassword = $sPassword;
     return $this->DefaultResponse($oAccount, __FUNCTION__, $this->oApiUsers->updateAccount($oAccount));
 }