Ver código fonte

fix(extension):优化认证配置文件加载逻辑当默认认证配置源无法获取时,添加异常处理机制并设置默认认证文件路径为 runtime/auth.json,
确保在配置文件不存在的情况下系统能够正常运行。

runphp 6 meses atrás
pai
commit
94bcd09f08
1 arquivos alterados com 7 adições e 3 exclusões
  1. 7 3
      src/Hook/AppStatusHook.php

+ 7 - 3
src/Hook/AppStatusHook.php

@@ -25,9 +25,13 @@ class AppStatusHook
         private readonly Config $config,
     )
     {
-        $authConfigSource = Factory::createConfig()->getAuthConfigSource();
-        $authFile = $authConfigSource->getName();
-        if (!file_exists($authFile)) {
+        try {
+            $authConfigSource = Factory::createConfig()->getAuthConfigSource();
+            $authFile = $authConfigSource->getName();
+            if (!file_exists($authFile)) {
+                $authFile = root_path('runtime').'auth.json';
+            }
+        } catch (\RuntimeException) {
             $authFile = root_path('runtime').'auth.json';
         }
         $authJsonArr = json_decode(file_get_contents($authFile), true);