cozy / cozy-client-js

Javascript library to write Cozy applications
https://docs.cozy.io/en/cozy-client-js/README/
MIT License
11 stars 12 forks source link

fix: BREAKING CHANGE detect expired token and reload page #247

Closed y-lohse closed 6 years ago

y-lohse commented 6 years ago

There are weird situations where the app's cookie doesn't match the actual session cookie. When that happens, all XHR calls will fail until the cookie is fixed. The proper way to fix the cookie is to reload the page with a ?disconnect=1 parameter.

I've done this, but since the change is at such a low level, this will impact every app that uses cozy-client-js. Which is probably what we want.

The redirection only happens if we're actually on an app page in a browser. So if you're in node.js, or on file://whatever in a cordova or electron app, this change shouldn't affect you at all. If, for some reason, you don't want the page reload, or want to handle the error yourself, you can supply a new option to cozy.client.init. onInvalidTokenError can be a function, or it can be false/null to do nothing at all.

y-lohse commented 6 years ago

Détecter l'expiration de cookies