for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Thinktomorrow\Chief\App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class AuthenticateSuperadmin
{
use AuthorizesRequests;
/**
* The Guard implementation.
*
* @var Guard
*/
protected $auth;
* Create a new middleware instance.
* @param Guard $auth
* @return void
public function __construct(Guard $auth)
$this->auth = $auth;
}
* Handle an incoming request.
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
public function handle($request, Closure $next)
// Low level way to only allow TT users
// this is not a safe way to handle security and is only used for convenience, not to secure page restriction!!
if (! $this->auth->user() || ! $this->authorize('update-squanto')) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('admin/login');
return $next($request);