File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 33namespace App \Http \Middleware ;
44
55use Closure ;
6- use Route ,URL ,Auth ;
6+ use Route , URL , Auth ;
77
88class AuthenticateAdmin
99{
1010
1111 protected $ except = [
12- 'admin/index '
12+ 'admin/index ' ,
1313 ];
1414
1515 /**
@@ -20,17 +20,18 @@ class AuthenticateAdmin
2020 */
2121 public function handle ($ request , Closure $ next )
2222 {
23- if (Auth::guard ('admin ' )->user ()->id === 1 ){
23+ if (Auth::guard ('admin ' )->user ()->id === 1 ) {
2424 return $ next ($ request );
2525 }
2626
2727 $ previousUrl = URL ::previous ();
28- if (!\Gate::check (Route::currentRouteName ())) {
29- if ($ request ->ajax () && ($ request ->getMethod () != 'GET ' )) {
28+ $ routeName = starts_with (Route::currentRouteName (), 'admin. ' ) ? Route::currentRouteName () : 'admin. ' . Route::currentRouteName ();
29+ if (!\Gate::check ($ routeName )) {
30+ if ($ request ->ajax () && ($ request ->getMethod () != 'GET ' )) {
3031 return response ()->json ([
3132 'status ' => -1 ,
32- 'code ' => 403 ,
33- 'msg ' => '您没有权限执行此操作 '
33+ 'code ' => 403 ,
34+ 'msg ' => '您没有权限执行此操作 ' ,
3435 ]);
3536 } else {
3637 return response ()->view ('admin.errors.403 ' , compact ('previousUrl ' ));
You can’t perform that action at this time.
0 commit comments