File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ class DevAuthMiddleware
2424 */
2525 public function handle (Request $ request , Closure $ next )
2626 {
27+ if (! App::environment ('local ' )) {
28+ return $ next ($ request );
29+ }
30+
2731 $ user = $ this ->validate ($ request , $ next );
2832
2933 Auth::setUser ($ user );
@@ -38,12 +42,8 @@ public static function resolveUserUsing(Closure $resolveUser): string
3842 return static ::class;
3943 }
4044
41- protected function validate (Request $ request , Closure $ next ): ? Authenticatable
45+ protected function validate (Request $ request , Closure $ next )
4246 {
43- if (! App::environment ('local ' )) {
44- return $ next ($ request );
45- }
46-
4747 if ($ request ->header ('Authorization ' ) !== 'Bearer ' . config ('developer.auth.bearer ' , 'testing ' )) {
4848 return $ next ($ request );
4949 }
Original file line number Diff line number Diff line change 44
55use Binarcode \LaravelDeveloper \Tests \Fixtures \User ;
66use Closure ;
7+ use Illuminate \Contracts \Auth \Authenticatable ;
78use Illuminate \Http \Request ;
9+ use Illuminate \Support \Facades \App ;
810
911class DevSanctumAuthMiddleware extends DevAuthMiddleware
1012{
1113 public function handle (Request $ request , Closure $ next )
1214 {
15+ if (! App::environment ('local ' )) {
16+ return $ next ($ request );
17+ }
18+
1319 /**
1420 * @var User $user
1521 */
1622 $ user = $ this ->validate ($ request , $ next );
1723
24+ if (! $ user instanceof Authenticatable) {
25+ return $ next ($ request );
26+ }
27+
1828 if (! in_array (\Laravel \Sanctum \HasApiTokens::class, class_uses_recursive ($ user ))) {
1929 return $ next ($ request );
2030 }
You can’t perform that action at this time.
0 commit comments