]> _ Git - cubist_cms-back.git/commitdiff
wip #3316 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Jan 2020 18:38:17 +0000 (19:38 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 8 Jan 2020 18:38:17 +0000 (19:38 +0100)
composer.json
src/CookieServiceProvider.php [new file with mode: 0644]
src/app/Middleware/StartSession.php [new file with mode: 0644]

index 37c729a5494d6851ecdb045be0e3117bd8160707..0d10c53609a89665ae73dfd1976a910ed5abf5be 100644 (file)
         },
         "laravel": {
             "providers": [
-                "Cubist\\Backpack\\CubistBackpackServiceProvider"
+                "Cubist\\Backpack\\CubistBackpackServiceProvider",
+                "Cubist\\Backpack\\CookieServiceProvider"
+            ],
+            "dont-discover": [
+                "Illuminate\\Cookie\\CookieServiceProvider"
             ],
             "aliases": {
                 "CubistMenu": "Cubist\\Backpack\\app\\Magic\\Menu\\Facade",
diff --git a/src/CookieServiceProvider.php b/src/CookieServiceProvider.php
new file mode 100644 (file)
index 0000000..2c6c1ad
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+namespace Cubist\Backpack;
+
+use Illuminate\Cookie\CookieJar;
+use Illuminate\Cookie\CookieServiceProvider as Base;
+
+class CookieServiceProvider extends Base
+{
+    public function register()
+    {
+        $this->app->singleton('cookie', function ($app) {
+            $config = $app->make('config')->get('session');
+
+            $domains = explode(',', $config['domain']);
+            if (count($domains) === 1) {
+                $domain = $domains[0];
+            } else {
+                foreach ($domains as $domain) {
+                    if (stripos($_SERVER['HTTP_HOST'], $domain) !== false) {
+                        break;
+                    }
+                }
+            }
+
+            return (new CookieJar)->setDefaultPathAndDomain(
+                $config['path'], $domain, $config['secure'], $config['same_site'] ?? null
+            );
+        });
+    }
+}
diff --git a/src/app/Middleware/StartSession.php b/src/app/Middleware/StartSession.php
new file mode 100644 (file)
index 0000000..c60d888
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Middleware;
+
+use Illuminate\Session\Middleware\StartSession as Base;
+
+class StartSession extends Base
+{
+
+}