From ecb56702c3d734c23c16e7ec354b48ecf91ae295 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 29 Mar 2018 11:11:00 +0300 Subject: [PATCH] Improve consent cookie domain --- app/Constants/Domain.php | 15 +++++++++++++++ resources/views/master.blade.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Constants/Domain.php b/app/Constants/Domain.php index d8a0ff9b043f..613d89f62bce 100644 --- a/app/Constants/Domain.php +++ b/app/Constants/Domain.php @@ -2,6 +2,8 @@ namespace App\Constants; +use App\Libraries\Utils; + class Domain { const INVOICENINJA_COM = 1; @@ -28,4 +30,17 @@ class Domain { return 'maildelivery@' . static::getDomainFromId($id); } + + public static function getCookieDomain($url) + { + if (! Utils::isNinjaProd() || Utils::isReseller()) { + return ''; + } + + if (strpos($url, '.services') !== false) { + return '.invoice.services'; + } else { + return '.invoiceninja.com'; + } + } } diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index 8ea8a92f8542..67caf07680ea 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -212,7 +212,7 @@ }, }, "cookie": { - "domain": "{{ config('session.domain') }}" + "domain": "{{ App\Constants\Domain::getCookieDomain(request()->url) }}" }, "content": { "href": "{{ Utils::isNinja() ? Utils::getPrivacyLink() : (config('ninja.privacy_policy_url') ?: 'https://cookiesandyou.com/' ) }}",