AntonLV 5 лет назад
Родитель
Сommit
bd68e93417

+ 21 - 22
modules/boonex/api/classes/BxApiModule.php

@@ -430,25 +430,26 @@ class BxApiModule extends BxDolModule
      * }
      * @endcode
      */
-    public function serviceResetPasswordCheckCode(){
-		$sKey = bx_get('code');
-        
-        if ($sKey == ''){
-			return array(
+    public function serviceResetPasswordCheckCode() {
+        $sKey = bx_get('code');
+
+        if ($sKey == '') {
+            return array(
                 'code' => 404,
                 'error' => 'No Content',
                 'desc' => 'Validation code can\'t be empty',
             );
-		}
+        }
 
         $oKey = BxDolKey::getInstance();
-        if (!$oKey || !$oKey->isKeyExists($sKey)){
+        if (!$oKey || !$oKey->isKeyExists($sKey)) {
             return array(
                 'code' => 404,
                 'error' => 'Wrong code',
                 'desc' => 'Validation code is not exist or expired',
             );
         }
+
         $aData = $oKey->getKeyData($sKey);
         if (!isset($aData['email'])){
             return array(
@@ -458,34 +459,32 @@ class BxApiModule extends BxDolModule
             );
         }
 
-		$oAccountQuery = BxDolAccountQuery::getInstance();
+        $oAccountQuery = BxDolAccountQuery::getInstance();
         $iAccountId = $oAccountQuery->getIdByEmail($aData['email']);
-        if (!$iAccountId){
+        if (!$iAccountId) {
             return array(
                 'code' => 404,
                 'error' => 'Wrong code',
                 'desc' => 'Validation code is not exist or expired',
             );
         }
-        
-		$oBxTemplServiceAccount = new BxTemplServiceAccount();
+
+        $oBxTemplServiceAccount = new BxTemplServiceAccount();
         $sPassword = $oBxTemplServiceAccount->generateUserNewPwd($iAccountId);
 
         $oKey->removeKey($sKey);
 
         $aPlus = array ('password' => $sPassword);
-		
-		$aTemplate = BxDolEmailTemplates::getInstance() -> parseTemplate('t_PasswordReset', $aPlus, $iAccountId);
+        $aTemplate = BxDolEmailTemplates::getInstance() -> parseTemplate('bx_api_password_reset', $aPlus, $iAccountId);
 
-		$oAccountQuery = BxDolAccountQuery::getInstance();
-		$oAccountQuery->unlockAccount($iAccountId);
-		
-        if ($aTemplate && sendMail($aData['email'], $aTemplate['Subject'], $aTemplate['Body'], 0, $aPlus, BX_EMAIL_SYSTEM)){
-			return array(
-				'code' => 200,
-				'password' => $sPassword,
-			);
-		}
+        $oAccountQuery->unlockAccount($iAccountId);
+
+        if ($aTemplate && sendMail($aData['email'], $aTemplate['Subject'], $aTemplate['Body'], 0, $aPlus, BX_EMAIL_SYSTEM)) {
+            return array(
+                'code' => 200,
+                'password' => $sPassword,
+            );
+        }
     }
     
     /**

+ 12 - 2
modules/boonex/api/install/langs/en.xml

@@ -1,5 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources name="en" flag="gb" title="English">
-	<string name="_sys_module_api"><![CDATA[API]]></string>
-	<string name="_bx_api"><![CDATA[API]]></string>
+    <string name="_sys_module_api"><![CDATA[API]]></string>
+    <string name="_bx_api"><![CDATA[API]]></string>
+
+    <!-- EMAIL TEMPLATES -->
+    <string name="_bx_api_et_txt_name_password_reset"><![CDATA[New password message]]></string>
+    <string name="_bx_api_et_txt_subject_password_reset"><![CDATA[Your new password]]></string>
+    <string name="_bx_api_et_txt_body_password_reset"><![CDATA[{email_header}
+<p>Your new password is:</p>
+<p> </p>
+<p><b>{password}</b></p>
+<p> </p>
+{email_footer}]]></string>
 </resources>

+ 3 - 0
modules/boonex/api/install/sql/disable.sql

@@ -0,0 +1,3 @@
+
+-- EMAIL TEMPLATES
+DELETE FROM `sys_email_templates` WHERE `Module` = 'bx_api';

+ 3 - 3
modules/boonex/api/install/sql/enable.sql

@@ -1,4 +1,4 @@
 
-
-
-
+-- EMAIL TEMPLATES
+INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES 
+('bx_api', '_bx_api_et_txt_name_password_reset', 'bx_api_password_reset', '_bx_api_et_txt_subject_password_reset', '_bx_api_et_txt_body_password_reset');