Skip to content

Commit

Permalink
Merge pull request #556 from cocrafts/hieu/ms-242-clean-up-w3a-after-…
Browse files Browse the repository at this point in the history
…logging-out

fix: clean up w3a after logging out
  • Loading branch information
tanlethanh authored Jun 11, 2024
2 parents 20e9056 + 57206a7 commit 175e1f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions apps/wallet/src/utils/auth/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { appActions } from 'state/app';

import { storage } from '../storage';

import { tkey } from './w3a';

export const logout = async () => {
await firebase.auth().signOut();
await engine.clear();
await storage.clearAllDocs();
appActions.cleanupAfterLogOut();
tkey.shares = {};
};
3 changes: 3 additions & 0 deletions apps/wallet/src/utils/auth/logout.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { appActions } from 'state/app';
import { auth } from '../firebase/index.web';
import { storage } from '../storage';

import { tkey } from './w3a';

export const logout = async () => {
await signOut(auth());
await engine.clear();
await storage.clearAllDocs();
appActions.cleanupAfterLogOut();
tkey.shares = {};
};
13 changes: 6 additions & 7 deletions apps/wallet/src/utils/auth/w3a/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { GenerateNewShareResult } from '@tkey/common-types';
import { logger } from '@walless/core';

import { importDeviceShare, initTkey, storeDeviceShare } from './tkey';
import { initTkey, storeDeviceShare } from './tkey';

export * from './core';

Expand All @@ -27,11 +26,11 @@ export enum ThresholdResult {
}

export const importAvailableShares = async (): Promise<ThresholdResult> => {
try {
await importDeviceShare(tkey);
} catch (e) {
logger.error('Existing share not available, skip..', e);
}
// try {
// await importDeviceShare(tkey);
// } catch (e) {
// logger.error('Existing share not available, skip..', e);
// }

const { requiredShares, totalShares } = tkey.getKeyDetails();
const isReady = requiredShares <= 0;
Expand Down

0 comments on commit 175e1f8

Please sign in to comment.