From 87becaf5c07e44532dcd1276a7fe9114b201470f Mon Sep 17 00:00:00 2001 From: Philippe Maes Date: Sat, 7 Nov 2020 11:40:15 +0100 Subject: [PATCH] Logout ability --- src/components/NavigationFrame.js | 8 ++++++++ src/utils/wallet-seed.js | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/components/NavigationFrame.js b/src/components/NavigationFrame.js index 09228a7..6a8c6d6 100644 --- a/src/components/NavigationFrame.js +++ b/src/components/NavigationFrame.js @@ -9,9 +9,11 @@ import Menu from '@material-ui/core/Menu'; import MenuItem from '@material-ui/core/MenuItem'; import { clusterApiUrl } from '@solana/web3.js'; import { useWalletSelector } from '../utils/wallet'; +import { forgetWallet } from '../utils/wallet-seed'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import CheckIcon from '@material-ui/icons/Check'; import AddIcon from '@material-ui/icons/Add'; +import ExitToApp from '@material-ui/icons/ExitToApp'; import AccountIcon from '@material-ui/icons/AccountCircle'; import Divider from '@material-ui/core/Divider'; import Hidden from '@material-ui/core/Hidden'; @@ -188,6 +190,12 @@ function WalletSelector() { Create Account + + + + + Logout + ); diff --git a/src/utils/wallet-seed.js b/src/utils/wallet-seed.js index 7f36682..1749077 100644 --- a/src/utils/wallet-seed.js +++ b/src/utils/wallet-seed.js @@ -111,3 +111,13 @@ async function deriveEncryptionKey(password, salt, iterations, digest) { export function lockWallet() { setUnlockedMnemonicAndSeed(null, null); } + +export function forgetWallet() { + localStorage.removeItem('walletIndex'); + localStorage.removeItem('walletCount'); + localStorage.removeItem('locked'); + localStorage.removeItem('unlocked'); + sessionStorage.removeItem('unlocked'); + unlockedMnemonicAndSeed = { mnemonic: null, seed: null }; + walletSeedChanged.emit('change', unlockedMnemonicAndSeed); +}