Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Middleware/AuthenticateAdmin.php
- This file was copied to src/app/Http/Middleware/AuthenticateReseller.php.
Show All 12 Lines | class AuthenticateAdmin | ||||
* @param \Closure $next | * @param \Closure $next | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function handle($request, Closure $next) | public function handle($request, Closure $next) | ||||
{ | { | ||||
$user = auth()->user(); | $user = auth()->user(); | ||||
if (!$user) { | if (!$user) { | ||||
abort(403, "Unauthorized"); | abort(401, "Unauthorized"); | ||||
} | } | ||||
if ($user->role !== "admin") { | if ($user->role !== "admin") { | ||||
abort(403, "Unauthorized"); | abort(403, "Unauthorized"); | ||||
} | } | ||||
return $next($request); | return $next($request); | ||||
} | } | ||||
} | } |