File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 44
55use App \Policies \UserPolicy ;
66use App \User ;
7- use Auth ;
87use Closure ;
98use Illuminate \Http \Request ;
9+ use Illuminate \Support \Facades \Auth ;
1010use Symfony \Component \HttpKernel \Exception \HttpException ;
1111
1212class VerifyAdmins
1313{
1414 public function handle (Request $ request , Closure $ next , $ guard = null )
1515 {
16- if (! Auth::guard ($ guard )->user ()->can (UserPolicy::ADMIN , User::class)) {
17- throw new HttpException ( 403 , ' Forbidden ' );
16+ if (Auth::guard ($ guard )->user ()->can (UserPolicy::ADMIN , User::class)) {
17+ return $ next ( $ request );
1818 }
1919
20- return $ next ( $ request );
20+ throw new HttpException ( 403 , ' Forbidden ' );
2121 }
2222}
Original file line number Diff line number Diff line change 1- <div class =" flex flex-col mb-4 w-full @if (isset ($centered ) && $centered ) items-center @endif " >
1+ <div class =" flex flex-col mb-4 w-full @if (isset ($centered ) && $centered ) items-center @endif " >
22 <div class =" mb-4" >
3- @can (App \Policies \UserPolicy:: ADMIN , App \User:: class )
4- <a href =" {{ route (' admin.users.show' , $user -> username ()) } }" >
5- <img src =" {{ $user -> gravatarUrl ($avatarSize ?? 250 ) } }" class =" w-full" >
6- </a >
7- @else
8- <a href =" {{ route (' profile' , $user -> username ()) } }" >
9- <img src =" {{ $user -> gravatarUrl ($avatarSize ?? 250 ) } }" class =" w-full" >
10- </a >
11- @endcan
3+ <a href =" {{ route (' profile' , $user -> username ()) } }" >
4+ <img src =" {{ $user -> gravatarUrl ($avatarSize ?? 250 ) } }" class =" w-full" >
5+ </a >
126 </div >
137
148 <h2 class =" text-2xl text-gray-900 mb-4" >{{ $user -> name () } } </h2 >
2721 @endif
2822 @endcan
2923
30- @if (Auth:: check () && Auth:: user ()-> isAdmin () )
24+ @if (Auth:: check () && Auth:: user ()-> isAdmin () )
3125 @can (App \Policies \UserPolicy:: DELETE , $user )
3226 <button type =" button" class =" button button-danger w-full mb-4" @click .prevent =" activeModal = 'deleteUser'" >Delete User</button >
3327 @endcan
You can’t perform that action at this time.
0 commit comments