Просмотр исходного кода

#3248 Password reset isn't logged in audit and no alert

Alex Trofimov 5 лет назад
Родитель
Сommit
d6929eb04d
2 измененных файлов с 5 добавлено и 4 удалено
  1. 2 1
      inc/classes/BxDolAccount.php
  2. 3 3
      template/scripts/BxBaseServiceAccount.php

+ 2 - 1
inc/classes/BxDolAccount.php

@@ -244,8 +244,9 @@ class BxDolAccount extends BxDolFactory implements iBxDolSingleton
         $sSalt = genRndSalt();
         $sPasswordHash = encryptUserPwd($sPassword, $sSalt);
         $iId = (int)$iAccountId ? (int)$iAccountId : $this->_iAccountID;
+        $oAccountSender = BxDolAccount::getInstance();
         if((int)BxDolAccountQuery::getInstance()->updatePassword($sPasswordHash, $sSalt, $iId) > 0) {
-            bx_alert('account', 'edited', $iId, BxDolAccount::getInstance()->id(), array('action' => 'reset_password'));
+            bx_alert('account', 'edited', $iId, $oAccountSender ? $oAccountSender->id() : $iId, array('action' => 'reset_password'));
             $this->doAudit($iId, '_sys_audit_action_account_reset_password');
             return true;
         }

+ 3 - 3
template/scripts/BxBaseServiceAccount.php

@@ -535,9 +535,9 @@ class BxBaseServiceAccount extends BxDol
                 return MsgBox(_t('_sys_txt_reset_pasword_error_not_found', $sErrorUrl));;
 
             $sPassword = $oForm->getCleanValue('password');
-            $sSalt = genRndSalt();
-            if(!$this->_oAccountQuery->updatePassword(encryptUserPwd($sPassword, $sSalt), $sSalt, $iAccountId))
-                return MsgBox(_t('_sys_txt_reset_pasword_error_occured', $sErrorUrl));;
+            $oAccount = BxDolAccount::getInstance($iAccountId);
+            if (!$oAccount || !$oAccount->updatePassword($sPassword))
+                return MsgBox(_t('_sys_txt_reset_pasword_error_occured', $sErrorUrl));
 
             $this->_oAccountQuery->unlockAccount($iAccountId);
             $oKey->removeKey($sKey);