A
A
Alexander2017-06-18 00:23:50
Laravel
Alexander, 2017-06-18 00:23:50

How to update jwt token in vue js?

Hello! Can someone please explain how to update the jwt token? I created a route in laravel:

Route::get('/refresh-token', [
    'uses' => '[email protected]',
    'middleware' => 'auth.jwt'
]);

And in the controller I send json with a new token. But what to do on the client? There is an idea to stupidly check in each request and update the token in catch. But the solution is not the best. How can this be done more elegantly? Thanks everybody

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-06-18
@kulakoff Vue.js

As an option, use two tokens, one access token, another refresh token. The first one has a short lifetime, the second one has a long one. When authenticating, you get both of these tokens on the client and save them in localStorage, for access you use the access token. Once it dies, catch it and get new tokens by making a /refresh-token request using a refresh token.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question