FAForever / website

FAForever's Website
http://www.faforever.com
MIT License
21 stars 37 forks source link

Passport refresh token if stale #478

Open fcaps opened 1 year ago

fcaps commented 1 year ago

The website session is longer than the token ttl from hydra, so you can be logged in while your token is outdated. To combat this we need some automatic check if the token is stale and refresh it if possible.

For axios it could look like:

instance.interceptors.request.use(config => {
    if (token.expired()) {
      token = token.refresh()
    }

    config.headers['Authorization'] = `Bearer ${token.token.access_token}`;
    return config;
  });

open questions: