How to validate a token?

Asked

Viewed 509 times

0

I have an api in Passport, in my front end that is in React I created a private route, in this private route I called a function checkAuth, to know the user ta authenticated, but for now I made this function by passing true or false to test, as a beginner, when I tried to check if the token is true or not, I ended up crashing, because I do not know how to do or where to start, I would need a practical example, if someone can help me, I appreciate!

Until the part of checking user and password, generate the token and store it in the location ta ok Torage. I just need to check if this token is true or has not been changed, thanks in advance!

1 answer

0


You do not need to validate it, if your private route is within the Passport authentication middleware it will already validate automatically for you, you do not need to keep performing these checks.

Route::middleware('auth:api')->group(function () {
    // rotas que serão validadas e só passarão se vc tiver logado com token válido
    Route::get('user', 'PassportController@details');
});

https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13

  • Thanks bro <3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.