Logout ability

This commit is contained in:
Philippe Maes 2020-11-07 11:40:15 +01:00
parent 4c45341e31
commit 87becaf5c0
2 changed files with 18 additions and 0 deletions

View File

@ -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() {
</ListItemIcon>
Create Account
</MenuItem>
<MenuItem onClick={forgetWallet}>
<ListItemIcon className={classes.menuItemIcon}>
<ExitToApp fontSize="small" />
</ListItemIcon>
Logout
</MenuItem>
</Menu>
</>
);

View File

@ -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);
}