archive password when new paasword is created (#1380)

This commit is contained in:
Fouad
2022-06-16 16:02:36 +01:00
committed by GitHub
parent 287c45d6b5
commit 6bd0ff796a
2 changed files with 8 additions and 19 deletions
@@ -3,8 +3,8 @@ import { useNavigate } from 'react-router-dom';
import { Button, CircularProgress, FormControl, Stack } from '@mui/material';
import { useSnackbar } from 'notistack';
import { AuthContext } from 'src/context/auth';
import { createPassword } from 'src/requests';
import { PasswordInput } from 'src/components';
import { archiveWalletFile, createPassword, isPasswordCreated } from 'src/requests';
import { Subtitle, Title, PasswordStrength } from '../components';
export const ConnectPassword = () => {
@@ -20,6 +20,12 @@ export const ConnectPassword = () => {
const storePassword = async () => {
try {
setIsLoading(true);
const exists = await isPasswordCreated();
if (exists) {
await archiveWalletFile();
}
await createPassword({ mnemonic, password });
resetState();
enqueueSnackbar('Password successfully created', { variant: 'success' });
@@ -2,32 +2,15 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';
import { Button, Stack, Typography } from '@mui/material';
import { useSnackbar } from 'notistack';
import { archiveWalletFile } from 'src/requests';
import { Console } from 'src/utils/console';
import { Subtitle } from '../components';
export const ForgotPassword = () => {
const navigate = useNavigate();
const { enqueueSnackbar } = useSnackbar();
return (
<>
<Subtitle subtitle="Create a new password or sign in with mnemonic" />
<Stack spacing={2} sx={{ width: 300 }}>
<Button
variant="contained"
size="large"
onClick={async () => {
try {
await archiveWalletFile();
} catch (e) {
Console.error(e);
enqueueSnackbar('Failed to archive your existing wallet file', { variant: 'error' });
}
navigate('/confirm-mnemonic');
}}
fullWidth
>
<Button variant="contained" size="large" onClick={() => navigate('/confirm-mnemonic')} fullWidth>
Create a new password
</Button>
<Typography sx={{ textAlign: 'center', fontWeight: 600 }}>or</Typography>