Browse Source

Fix: 多应用后台登录后跳转

seth-shi 4 years ago
parent
commit
8ce41a71b0
2 changed files with 19 additions and 3 deletions
  1. 8 0
      src/Application.php
  2. 11 3
      src/Http/Controllers/AuthController.php

+ 8 - 0
src/Application.php

@@ -42,6 +42,14 @@ class Application
         $this->apps = (array) config('admin.multi_app');
     }
 
+    /**
+     * 获取已经启用的 app 列表
+     */
+    public function enableApps()
+    {
+        return array_filter($this->apps);
+    }
+
     /**
      * 设置当前应用配置.
      *

+ 11 - 3
src/Http/Controllers/AuthController.php

@@ -3,6 +3,7 @@
 namespace Dcat\Admin\Http\Controllers;
 
 use Dcat\Admin\Admin;
+use Dcat\Admin\Application;
 use Dcat\Admin\Form;
 use Dcat\Admin\Http\Repositories\Administrator;
 use Dcat\Admin\Layout\Content;
@@ -241,10 +242,17 @@ class AuthController extends Controller
     {
         $request->session()->regenerate();
 
-        return $this->response()
+        $response = $this->response()
             ->success(trans('admin.login_successful'))
-            ->locationToIntended($this->getRedirectPath())
-            ->send();
+            ->locationToIntended($this->getRedirectPath());
+
+        // 如果当前启用了多应用后台,
+        // 不要跳去 session 存储的 path
+        if (! empty(Admin::app()->enableApps())) {
+            $response->location($this->getRedirectPath());
+        }
+
+        return $response->send();
     }
 
     /**