mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-30 12:43:57 -06:00
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* IsSandStormUser.php
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
*
|
|
* This file is part of Firefly III.
|
|
*
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
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 === intval(getenv('SANDSTORM'))) {
|
|
Session::flash('warning', strval(trans('firefly.sandstorm_not_available')));
|
|
|
|
return redirect(route('index'));
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|