2020-10-12 14:00:09 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Http\Response;
|
2021-10-15 23:46:21 +02:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2020-10-12 14:00:09 +02:00
|
|
|
|
2022-03-29 15:02:43 +02:00
|
|
|
class RejectIfDemoMode
|
2020-10-12 14:00:09 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
|
2021-10-01 13:34:28 +02:00
|
|
|
if( config('2fauth.config.isDemoApp') ) {
|
2022-03-29 15:02:43 +02:00
|
|
|
Log::notice('Cannot request this action in Demo mode');
|
2021-10-15 23:46:21 +02:00
|
|
|
|
2022-03-28 13:48:29 +02:00
|
|
|
return response()->json(['message' => __('auth.forms.disabled_in_demo')], Response::HTTP_UNAUTHORIZED);
|
2020-10-12 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|