mirror of
https://github.com/standardnotes/mobile.git
synced 2026-05-24 22:44:41 -04:00
Fix clearing all data on signout
This commit is contained in:
@@ -12,6 +12,7 @@ import KeysManager from './lib/keysManager'
|
||||
import Auth from './lib/sfjs/authManager'
|
||||
import ModelManager from './lib/sfjs/modelManager'
|
||||
import Sync from './lib/sfjs/syncManager'
|
||||
import Storage from './lib/sfjs/storageManager'
|
||||
import ReviewManager from './lib/reviewManager';
|
||||
import GlobalStyles from "./Styles"
|
||||
import Icons from "./Icons"
|
||||
@@ -78,6 +79,7 @@ export default class App {
|
||||
this.signoutObserver = Auth.get().addEventHandler((event) => {
|
||||
if(event == SFAuthManager.DidSignOutEvent) {
|
||||
this.optionsState.reset();
|
||||
Storage.get().clearAllModels();
|
||||
KeysManager.get().clearAccountKeysAndData();
|
||||
ModelManager.get().handleSignout();
|
||||
Sync.get().handleSignout();
|
||||
|
||||
@@ -125,10 +125,15 @@ export default class KeysManager {
|
||||
this.loadLocalStateFromKeys(null);
|
||||
this.accountAuthParams = null;
|
||||
this.user = null;
|
||||
Storage.get().setItem(FirstRunKey, "false")
|
||||
Storage.get().setItem(FirstRunKey, "false");
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
/*
|
||||
We need to register local storage keys, so that when we want to sign out, we don't accidentally
|
||||
clear internal keys, like first_run. (If you accidentally delete the first_run key when you sign out,
|
||||
then the next time you sign in and refresh, it will treat it as a new run, and delete all data.)
|
||||
*/
|
||||
registerAccountRelatedStorageKeys(storageKeys) {
|
||||
this.accountRelatedStorageKeys = _.uniq(this.accountRelatedStorageKeys.concat(storageKeys));
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ export default class Auth extends SFAuthManager {
|
||||
return !keys.jwt;
|
||||
}
|
||||
|
||||
async signout(clearAllData) {
|
||||
// DONT clear all data. We will do this ourselves manually, as we need to preserve certain data keys.
|
||||
super.signout(false);
|
||||
}
|
||||
|
||||
async getAuthParams() {
|
||||
return KeysManager.get().activeAuthParams();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user