. */ declare(strict_types=1); namespace FireflyIII\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Session; /** * Class IsSandStormUser. */ class IsSandStormUser { /** * Handle an incoming request. May not be a limited user (ie. Sandstorm env. or demo user). * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * * @return mixed */ public function handle(Request $request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { // don't care when not logged in, usual stuff applies: return $next($request); } if (1 === (int)getenv('SANDSTORM')) { Session::flash('warning', (string)trans('firefly.sandstorm_not_available')); return response()->redirectTo(route('index')); } return $next($request); } }