T
T
Taras252020-11-27 12:27:21
Vue.js
Taras25, 2020-11-27 12:27:21

VueJs - how to auto update jwt token when entering the site?

I think the question is generally clear.
And the main idea of ​​his solution is also - the user enters the site, if he has a pair of access / refresh tokens in the browser storage, then an automatic refresh occurs, and if the token is valid, then he receives a new pair of tokens, and isLoggedIn = true is written to Vuex, all authorization-dependent components reactively use this information and everything looks as it should.
But since In general, I'm just starting my way in the front-end, and I know Vue rather poorly (or rather, Quasar, which is based on it), maybe there is some common approach here? Is there a special module that needs to be written for this? And at what point should it be launched, how should it interact in general terms?
Not necessarily Vue, probably similar principles can be described for any SPA framework.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AzzecT, 2020-11-28
@AzzecT

Good afternoon, I confess that I have not worked with Quasar, but how could it be done with the same application created through vue-cli: we have a file Appthat is the root element (it already implements the necessary components on each page and router-view ). In this component App, in a hook, createdyou can call a function to check and refresh the token.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question