Support the ongoing development of Laravel.io →
Authentication Laravel Requests
Last updated 2 years ago.
0

Make sure that in your config/auth you have this:

'guards' => [
		'web' => [
				'driver' => 'session',
				'provider' => 'users',
		],

		'api' => [
				'driver' => 'passport',
				'provider' => 'users',
		],
],
	
	
	Then your API routes should be protected like this:
	
Route::group(['prefix' => 'v1', 'middleware' => ['auth:api'], function () {

});
	
	Now from here:
	[https://laravel.com/docs/5.8/authentication](http://)
	
Path Customization

When a user is successfully authenticated, they will be redirected to the /home URI. You can customize the post-authentication redirect location by defining a redirectTo property on the LoginController, RegisterController, ResetPasswordController, and VerificationController:

protected $redirectTo = '/'; Next, you should modify the RedirectIfAuthenticated middleware's handle method to use your new URI when redirecting the user.

If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property:

protected function redirectTo() { return '/path'; }

Hope this helps,

Ben

0

Visit Icetutor.com For Your Solution

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.