2FAuth/app/Http/Middleware/RejectIfDemoMode.php

28 lines
614 B
PHP
Raw Normal View History

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
2021-10-15 23:46:21 +02:00
use Illuminate\Support\Facades\Log;
class RejectIfDemoMode
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle($request, Closure $next)
{
2022-11-22 15:15:52 +01:00
if (config('2fauth.config.isDemoApp')) {
2022-10-18 17:34:56 +02:00
Log::info('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);
}
return $next($request);
}
}