Ken 2 settimane fa
parent
commit
0465703cca
2 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 1 0
      app/Constants/StepStatus.php
  2. 20 0
      app/Services/SecretService.php

+ 1 - 0
app/Constants/StepStatus.php

@@ -38,5 +38,6 @@ class StepStatus
 
 
     const MY_INPUT_OLD_SECRET = 23;//输入原账号秘钥
+    const MY_INPUT_SECRET_PASS = 24;//输入秘钥的查看密码
 
 }

+ 20 - 0
app/Services/SecretService.php

@@ -48,12 +48,29 @@ class SecretService
         switch ($stepStatus) {
             case StepStatus::MY_INPUT_OLD_SECRET:
                 return SecretService::inputOldSecret($chatId, $text, $messageId);
+            case StepStatus::MY_INPUT_SECRET_PASS:
+                return SecretService::showSecretKey();
+
             default:
                 return null;
         }
 
     }
 
+    private static function showSecretKey($chatId, $password, $messageId): array
+    {
+        $user = User::where('member_id', $chatId)->first();
+        if ($user->secret_pass === $password) {
+            $text = "秘钥:{$user->secret_key}\n\n";
+            $text .= "请保管好你的秘钥";
+            return [
+                'chat_id' => $chatId,
+                'text' => $text,
+            ];
+        }
+        return [];
+    }
+
     private static function view($chatId, $messageId): array
     {
         $text = "请输入查看密码";
@@ -63,6 +80,9 @@ class SecretService
             $user->secret_key = $secretKey;
             $user->save();
         }
+
+        Cache::put(get_step_key($chatId), StepStatus::MY_INPUT_SECRET_PASS);
+
         return [
             'chat_id' => $chatId,
             'text' => $text,