How to set web user session login and csrf token after passport oauth api login in Angular

When post a passport oauth api login in Angular, set login api use web routes middleware.

Route::post('/api/v1/login', 'API\[email protected]');
instead of use api.php:
Route::post('login', '[email protected]');

This will set a laravel_session in cookie, and you will only need use Angular http post request login once, no need to login from web form again.
You can directly access user home or admin panel use the same user.

Note, when submit form from api, we may need include the CSRF token to avoid issues. we can get it via csrf_token()

Leave a Reply

Your email address will not be published. Required fields are marked *