From ff3e23e7dab7a8197dc10d569ef20ea3c4b16808 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 9 Jan 2017 16:25:23 +0200 Subject: [PATCH] Improve white label logic #1264 --- app/Libraries/Utils.php | 18 +++++++++++++----- resources/views/master.blade.php | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 6412da69b280..4cb9af4a94f6 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -102,13 +102,21 @@ class Utils public static function isWhiteLabel() { - if (Utils::isNinjaProd()) { - return false; + $account = false; + + if (Utils::isNinja()) { + if (Auth::check()) { + $account = Auth::user()->account; + } elseif ($contactKey = session('contact_key')) { + if ($contact = \App\Models\Contact::whereContactKey($contactKey)->first()) { + $account = $contact->account; + } + } + } else { + $account = \App\Models\Account::first(); } - $account = \App\Models\Account::first(); - - return $account && $account->hasFeature(FEATURE_WHITE_LABEL); + return $account ? $account->hasFeature(FEATURE_WHITE_LABEL) : false; } public static function getResllerType() diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index 4fb3ceac264b..ac65af625cbe 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -1,7 +1,7 @@ - @if (!Utils::isNinja() && !Auth::check()) + @if (Utils::isWhiteLabel()) {{ trans('texts.client_portal') }} @else {{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}