Пример #1
0
 /**
  * @param \RainLoop\Account $oAccount
  * @param string $sPrevPassword
  * @param string $sNewPassword
  */
 public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
 {
     $mResult = false;
     if ($this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface && $this->PasswordChangePossibility($oAccount)) {
         if ($sPrevPassword !== $oAccount->Password()) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CurrentPasswordIncorrect);
         }
         $sPasswordForCheck = \trim($sNewPassword);
         if (6 > \strlen($sPasswordForCheck)) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordShort);
         }
         if (!\MailSo\Base\Utils::PasswordWeaknessCheck($sPasswordForCheck)) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordWeak);
         }
         if (!$this->oDriver->ChangePassword($oAccount, $sPrevPassword, $sNewPassword)) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
         }
         $oAccount->SetPassword($sNewPassword);
         $this->oActions->SetAuthToken($oAccount);
         $mResult = $this->oActions->GetSpecAuthToken();
     } else {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
     }
     return $mResult;
 }
Пример #2
0
 /**
  * @param \RainLoop\Account $oAccount
  * @param string $sPrevPassword
  * @param string $sNewPassword
  */
 public function ChangePassword(\RainLoop\Account $oAccount, $sPrevPassword, $sNewPassword)
 {
     if ($this->oDriver instanceof \RainLoop\Providers\ChangePassword\ChangePasswordInterface && $this->PasswordChangePossibility($oAccount)) {
         if ($sPrevPassword !== $oAccount->Password()) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CurrentPasswordIncorrect);
         }
         if (4 > \strlen($sNewPassword)) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordShort);
         }
         if ($this->bCheckWeak) {
             if (7 > \strlen($sNewPassword)) {
                 throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::NewPasswordWeak);
             }
         }
         if (!$this->oDriver->ChangePassword($oAccount, $sPrevPassword, $sNewPassword)) {
             throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
         }
         $oAccount->SetPassword($sNewPassword);
         $this->oActions->SetAuthToken($oAccount);
     } else {
         throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CouldNotSaveNewPassword);
     }
 }