From 041c89b4f8795ff323cd61deec42f65f82e49f88 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sat, 24 Feb 2018 22:20:21 +0200 Subject: [PATCH] We can't find a user with that e-mail address. #1444 --- app/Http/Middleware/Authenticate.php | 18 +++++++++++++++++- app/Libraries/Utils.php | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 852bef8abf..1aaca6fe38 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -2,10 +2,12 @@ namespace App\Http\Middleware; +use App\Models\Account; use App\Models\Contact; use App\Models\Invitation; use App\Models\ProposalInvitation; use Auth; +use Utils; use Closure; use Session; @@ -99,7 +101,21 @@ class Authenticate if ($request->ajax()) { return response('Unauthorized.', 401); } else { - return redirect()->guest($guard == 'client' ? '/client/login' : '/login'); + if ($guard == 'client') { + $url = '/client/login'; + if (Utils::isNinja()) { + if ($account && Utils::getSubdomain() == 'app') { + $url .= '?account_key=' . $account->account_key; + } + } else { + if ($account && Account::count() > 1) { + $url .= '?account_key=' . $account->account_key; + } + } + } else { + $url = '/login'; + } + return redirect()->guest($url); } } diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 3de9318251..5dab8479b5 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -1003,8 +1003,12 @@ class Utils return $str; } - public static function getSubdomain($url) + public static function getSubdomain($url = false) { + if (! $url) { + $url = Request::server('HTTP_HOST'); + } + $parts = parse_url($url); $subdomain = '';