Skip to content

Commit

Permalink
Merge pull request #10 from amiryousefi/add-api-guard-check
Browse files Browse the repository at this point in the history
Add support for api guard
  • Loading branch information
amiryousefi committed Apr 7, 2021
2 parents 07a2500 + 0f7b816 commit 2745cd5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Middleware/AuthRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ class AuthRoles
*/
public function handle($request, Closure $next)
{

$guard = auth('api')->check() ? 'api' : '';

throw_if(!auth()->check(), UnauthenticatedException::notLoggedIn());
throw_if(!auth($guard)->check(), UnauthenticatedException::notLoggedIn());

$action = $request->route()->getActionname();
$name = $request->route()->getActionname();

$role_id = auth()->user()->role_id;
$role_id = auth($guard)->user()->role_id;

$permission = Permission::where(function ($query)use ($action, $name){
$query->where('name', $name);
Expand Down

0 comments on commit 2745cd5

Please sign in to comment.