How to make basic laravel 5.5 auth work along JWT authentication?
Did you find a fix to this?
1- auth config
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
],
],
2- You need to tell basic auth to use web guard instead of api. You can achieve that by overriding guard() method inside auth controllers like LoginController and others. See Authentication Quickstart > Guard Customization
protected function guard()
{
return Auth::guard('web');
}
3-Last but not least, you need to make all controllers and routes guarded by auth to explicitly use web guard as they will use api by default because you have specified it as default guard.
Here is an example of HomeController
class HomeController extends Controller
{
public function __construct()
{
$this->middleware('auth:web');
}
}
Thats all :)
Most helpful comment
1- auth config
2- You need to tell basic auth to use
webguard instead ofapi. You can achieve that by overridingguard()method inside auth controllers likeLoginControllerand others. See Authentication Quickstart > Guard Customization3-Last but not least, you need to make all controllers and routes guarded by
authto explicitly usewebguard as they will useapiby default because you have specified it as default guard.Here is an example of
HomeControllerThats all :)