fix: Auth persistence to localStorage (#3078)
* fix: user, team, and policies should be persisted to localStorage for faster boot * capture instead of ignore errors
This commit is contained in:
@@ -68,19 +68,21 @@ export default class AuthStore {
|
||||
|
||||
try {
|
||||
data = JSON.parse(localStorage.getItem(AUTH_STORE) || "{}");
|
||||
} catch (_) {
|
||||
// no-op Safari private mode
|
||||
} catch (err) {
|
||||
Sentry.captureException(err);
|
||||
}
|
||||
|
||||
this.rehydrate(data);
|
||||
|
||||
// persists this entire store to localstorage whenever any keys are changed
|
||||
autorun(() => {
|
||||
try {
|
||||
localStorage.setItem(AUTH_STORE, this.asJson);
|
||||
} catch (_) {
|
||||
// no-op Safari private mode
|
||||
} catch (err) {
|
||||
Sentry.captureException(err);
|
||||
}
|
||||
});
|
||||
|
||||
// listen to the localstorage value changing in other tabs to react to
|
||||
// signin/signout events in other tabs and follow suite.
|
||||
window.addEventListener("storage", (event) => {
|
||||
|
||||
Reference in New Issue
Block a user