Improve white label logic #1264

This commit is contained in:
Hillel Coren 2017-01-09 16:25:23 +02:00
parent b697e2aafa
commit ff3e23e7da
2 changed files with 14 additions and 6 deletions

View File

@ -102,13 +102,21 @@ class Utils
public static function isWhiteLabel() public static function isWhiteLabel()
{ {
if (Utils::isNinjaProd()) { $account = false;
return 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) : false;
return $account && $account->hasFeature(FEATURE_WHITE_LABEL);
} }
public static function getResllerType() public static function getResllerType()

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{App::getLocale()}}"> <html lang="{{App::getLocale()}}">
<head> <head>
@if (!Utils::isNinja() && !Auth::check()) @if (Utils::isWhiteLabel())
<title>{{ trans('texts.client_portal') }}</title> <title>{{ trans('texts.client_portal') }}</title>
@else @else
<title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title> <title>{{ isset($title) ? ($title . ' | Invoice Ninja') : ('Invoice Ninja | ' . trans('texts.app_title')) }}</title>