-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
US-1872 Security - Can reset the wallet without auth (#734)
* feat: retry unlock if cancelled * feat: RetryLogin screen + Delete Wallet Modal refactor * chore: remove console.log * chore: put !__DEV__ back into unlockApp * fix: remove src/ alias from import * fix: android going back to CreateKeys
- Loading branch information
1 parent
ae203be
commit d652009
Showing
14 changed files
with
207 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { Dispatch, SetStateAction, useCallback, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { resetApp } from 'store/slices/settingsSlice' | ||
import { useAppDispatch } from 'store/storeUtils' | ||
import { sharedColors } from 'shared/constants' | ||
|
||
import { ConfirmationModal, ConfirmationModalConfig } from '..' | ||
|
||
interface Props { | ||
isVisible: boolean | ||
setVisible: Dispatch<SetStateAction<boolean>> | ||
} | ||
|
||
export const DeleteWalletModal = ({ isVisible, setVisible }: Props) => { | ||
const dispatch = useAppDispatch() | ||
const { t } = useTranslation() | ||
|
||
const eraseWallet = useCallback(() => { | ||
dispatch(resetApp()) | ||
}, [dispatch]) | ||
|
||
const createDeleteDefinitiveConfirmationConfig = useCallback( | ||
( | ||
createDeleteConfirmationConfigFn: () => ConfirmationModalConfig, | ||
): ConfirmationModalConfig => { | ||
return { | ||
color: sharedColors.dangerLight, | ||
title: t( | ||
'wallet_backup_definitive_delete_confirmation_title', | ||
) as string, | ||
titleColor: sharedColors.black, | ||
description: t( | ||
'wallet_backup_definitive_delete_confirmation_description', | ||
), | ||
descriptionColor: sharedColors.black, | ||
okText: t('Delete'), | ||
cancelText: t('Cancel'), | ||
buttons: [ | ||
{ color: sharedColors.black, textColor: sharedColors.white }, | ||
{ color: sharedColors.black, textColor: sharedColors.black }, | ||
], | ||
onOk: eraseWallet, | ||
onCancel: () => { | ||
console.log('ON CANCEL IN createDeleteDefinitiveConfirmationConfig') | ||
setVisible(false) | ||
setConfirmationModalConfig(createDeleteConfirmationConfigFn()) | ||
}, | ||
} | ||
}, | ||
[t, eraseWallet, setVisible], | ||
) | ||
|
||
const createDeleteConfirmationConfig = | ||
useCallback((): ConfirmationModalConfig => { | ||
return { | ||
color: sharedColors.dangerLight, | ||
title: t('wallet_backup_delete_confirmation_title') as string, | ||
titleColor: sharedColors.black, | ||
description: t( | ||
'wallet_backup_delete_confirmation_description', | ||
) as string, | ||
descriptionColor: sharedColors.black, | ||
okText: t('Delete') as string, | ||
cancelText: t('Cancel') as string, | ||
buttons: [ | ||
{ color: sharedColors.black, textColor: sharedColors.white }, | ||
{ color: sharedColors.black, textColor: sharedColors.black }, | ||
], | ||
onOk: () => { | ||
setConfirmationModalConfig( | ||
createDeleteDefinitiveConfirmationConfig( | ||
createDeleteConfirmationConfig, | ||
), | ||
) | ||
}, | ||
onCancel: () => { | ||
setVisible(false) | ||
}, | ||
} | ||
}, [t, createDeleteDefinitiveConfirmationConfig, setVisible]) | ||
|
||
const [confirmationModalConfig, setConfirmationModalConfig] = | ||
useState<ConfirmationModalConfig>(createDeleteConfirmationConfig) | ||
|
||
return ( | ||
<ConfirmationModal | ||
isVisible={isVisible} | ||
color={confirmationModalConfig.color} | ||
title={confirmationModalConfig.title} | ||
titleColor={confirmationModalConfig.titleColor} | ||
description={confirmationModalConfig.description} | ||
descriptionColor={confirmationModalConfig.descriptionColor} | ||
okText={confirmationModalConfig.okText} | ||
cancelText={confirmationModalConfig.cancelText} | ||
buttons={confirmationModalConfig.buttons} | ||
onOk={confirmationModalConfig.onOk} | ||
onCancel={confirmationModalConfig.onCancel} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useCallback, useState } from 'react' | ||
import { StyleSheet, View } from 'react-native' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { sharedColors, sharedStyles } from 'shared/constants' | ||
import { AppButton } from 'components/index' | ||
import { unlockApp } from 'store/slices/settingsSlice' | ||
import { castStyle } from 'shared/utils' | ||
import { DeleteWalletModal } from 'components/modal/deleteWalletModal' | ||
import { useAppDispatch } from 'store/storeUtils' | ||
|
||
export const RetryLogin = () => { | ||
const dispatch = useAppDispatch() | ||
const { t } = useTranslation() | ||
const [isDeleteConfirmationVisible, setIsDeleteConfirmationVisible] = | ||
useState<boolean>(false) | ||
|
||
const retryLogin = useCallback(() => { | ||
dispatch(unlockApp({})) | ||
}, [dispatch]) | ||
|
||
return ( | ||
<View style={[sharedStyles.screen, sharedStyles.contentCenter]}> | ||
<AppButton | ||
onPress={retryLogin} | ||
title={t('initial_screen_button_retry_login')} | ||
color={sharedColors.white} | ||
textColor={sharedColors.black} | ||
/> | ||
<AppButton | ||
onPress={() => setIsDeleteConfirmationVisible(true)} | ||
title={t('initial_screen_button_erase_wallet')} | ||
style={styles.btn} | ||
color={sharedColors.danger} | ||
textColor={sharedColors.white} | ||
/> | ||
<DeleteWalletModal | ||
isVisible={isDeleteConfirmationVisible} | ||
setVisible={setIsDeleteConfirmationVisible} | ||
/> | ||
</View> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
btn: castStyle.view({ | ||
marginTop: 12, | ||
}), | ||
}) |
Oops, something went wrong.