2022-01-15 05:58:33 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2022-01-15 05:58:33 +01:00
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use App\Utils\Ninja;
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class SessionDomains
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
* @param Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
2022-06-21 11:57:17 +02:00
|
|
|
if (Ninja::isSelfHost()) {
|
2022-01-15 05:58:33 +01:00
|
|
|
return $next($request);
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
2022-01-15 08:04:41 +01:00
|
|
|
|
|
|
|
$domain_name = $request->getHost();
|
|
|
|
|
2023-11-24 00:23:40 +01:00
|
|
|
if (strpos($domain_name, config('ninja.app_domain')) !== false) {
|
2022-06-21 11:57:17 +02:00
|
|
|
} else {
|
2022-01-15 12:08:48 +01:00
|
|
|
config(['session.domain' => $domain_name]);
|
2022-01-15 08:04:41 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
|
|
|
|
return $next($request);
|
2022-01-15 05:58:33 +01:00
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|