Skip to content

Commit

Permalink
Merge pull request #150 from vinicio328/patch-1
Browse files Browse the repository at this point in the history
Update VerifyRole.php
  • Loading branch information
jeremykenedy committed Mar 26, 2021
2 parents 17273bf + 21da883 commit 41f850b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/App/Http/Middleware/VerifyRole.php
Expand Up @@ -37,9 +37,12 @@ public function __construct(Guard $auth)
*/
public function handle($request, Closure $next, $role)
{
if ($this->auth->check() && $this->auth->user()->hasRole($role)) {
return $next($request);
}
$roles = explode("|", $role);
for($i = 0; $i < count($roles); ++$i) {
if ($this->auth->check() && $this->auth->user()->hasRole($roles[$i])) {
return $next($request);
}
}

throw new RoleDeniedException($role);
}
Expand Down

0 comments on commit 41f850b

Please sign in to comment.