mercredi 22 septembre 2021

Protect routes in Laravel with angular

I followed this tutorial https://remotestack.io/laravel-angular-jwt-token-based-authentication-example/ and it is working but issue is i'm able to access routes that should be not accessible without login. There is a route user-profile it can be accessed without login but i want it to redirect to login page in case user is not logged in.

api.php

Route::group([
    'middleware' => 'api',
    'prefix' => 'auth'
], function ($router) {
    Route::post('/signup', [JwtAuthController::class, 'register']);
    Route::post('/signin', [JwtAuthController::class, 'login']);
    Route::get('/user', [JwtAuthController::class, 'user']);
    Route::post('/token-refresh', [JwtAuthController::class, 'refresh']);
    Route::post('/signout', [JwtAuthController::class, 'signout']);

    Route::post('/req-password-reset', [ResetPwdReqController::class, 'reqForgotPassword']);
    Route::post('/update-password', [UpdatePwdController::class, 'updatePassword']);
}); 

Any Solution, Thanks



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/39sghrB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire