Procházet zdrojové kódy

feat: NC-45: 结算后台登陆增加邮箱验证码.

kevin před 1 rokem
rodič
revize
ef90f66aac

+ 1 - 1
backendApi/modules/v1/components/UserAuth.php

@@ -435,7 +435,7 @@ class UserAuth extends User
         $emailLogObj = new EmailLog();
         $emailLogObj = new EmailLog();
         $emailLogObj->ADMIN_ID = $admin['ID'];
         $emailLogObj->ADMIN_ID = $admin['ID'];
         $emailLogObj->EMAIL = $admin['EMAIL'];
         $emailLogObj->EMAIL = $admin['EMAIL'];
-        $emailLogObj->CODE = $result['CODE'];
+        $emailLogObj->CODE = $result;
         $emailLogObj->CREATED_AT = time();
         $emailLogObj->CREATED_AT = time();
         $emailLogObj->UPDATED_AT = time();
         $emailLogObj->UPDATED_AT = time();
         $emailLogObj->save();
         $emailLogObj->save();

+ 6 - 5
common/helpers/Email.php

@@ -8,9 +8,9 @@ class Email
 {
 {
     /**
     /**
      * @param string $email
      * @param string $email
-     * @return bool
+     * @return bool|string
      */
      */
-    public static function sendAdminLoginCode(string $email): bool
+    public static function sendAdminLoginCode(string $email)
     {
     {
         $subject = 'Elken Login Code';
         $subject = 'Elken Login Code';
         $code = Tool::randomString(6);
         $code = Tool::randomString(6);
@@ -18,12 +18,13 @@ class Email
 
 
         $mailer = Yii::$app->mailer;
         $mailer = Yii::$app->mailer;
         $mailer->useFileTransport = false;
         $mailer->useFileTransport = false;
-        return $mailer->compose()
-        ->setFrom('eshop-noreply@elken.com')
-//            ->setFrom(Yii::$app->params['adminEmail'])
+        $result = $mailer->compose()
+            ->setFrom('eshop-noreply@elken.com')
             ->setTo($email)
             ->setTo($email)
             ->setSubject($subject)
             ->setSubject($subject)
             ->setHtmlBody($message)
             ->setHtmlBody($message)
             ->send();
             ->send();
+
+        return !$result ? false : $code;
     }
     }
 }
 }