Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
<?php
declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Closure;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
class CatchBlockedUsers
{
/**
* Handle an incoming request.
*
* @param Request $request
*
* @return mixed
*
* @throws AuthenticationException
*/
public function handle($request, Closure $next)
{
if (auth()->check()) {
$user = auth()->user();
if (null !== $user) {
if (true === $user->blocked) {
throw new AuthenticationException(sprintf('User is not allowed to use the API ("%s")', $user->blocked_code));
}
}
}
return $next($request);
}
}