-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require a 2FA code to disable 2FA #48030
Changes from all commits
06a0010
1f706ca
d833650
0042dd3
61af1b2
65c3218
48360bc
5cd9a8e
0b6168b
7e4afd8
170d24d
1f6147e
c4e1a64
411ba53
782e954
6066f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type DisableTwoFactorAuthParams = { | ||
twoFactorAuthCode: string; | ||
}; | ||
|
||
export default DisableTwoFactorAuthParams; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, {useRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Button from '@components/Button'; | ||
import FixedFooter from '@components/FixedFooter'; | ||
import ScrollView from '@components/ScrollView'; | ||
import Text from '@components/Text'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import type {BackToParams} from '@libs/Navigation/types'; | ||
import StepWrapper from '@pages/settings/Security/TwoFactorAuth/StepWrapper/StepWrapper'; | ||
import useTwoFactorAuthContext from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthContext/useTwoFactorAuth'; | ||
import TwoFactorAuthForm from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm'; | ||
import type {BaseTwoFactorAuthFormOnyxProps, BaseTwoFactorAuthFormRef} from '@pages/settings/Security/TwoFactorAuth/TwoFactorAuthForm/types'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
type GetCodeProps = BaseTwoFactorAuthFormOnyxProps & BackToParams; | ||
|
||
function GetCode({account}: GetCodeProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
|
||
const formRef = useRef<BaseTwoFactorAuthFormRef>(null); | ||
|
||
const {setStep} = useTwoFactorAuthContext(); | ||
|
||
return ( | ||
<StepWrapper | ||
title={translate('twoFactorAuth.disableTwoFactorAuth')} | ||
shouldEnableKeyboardAvoidingView={false} | ||
onBackButtonPress={() => setStep(CONST.TWO_FACTOR_AUTH_STEPS.ENABLED, CONST.ANIMATION_DIRECTION.OUT)} | ||
onEntryTransitionEnd={() => formRef.current && formRef.current.focus()} | ||
> | ||
<ScrollView contentContainerStyle={styles.flexGrow1}> | ||
<View style={[styles.ph5, styles.mt3]}> | ||
<Text>{translate('twoFactorAuth.explainProcessToRemove')}</Text> | ||
</View> | ||
</ScrollView> | ||
<FixedFooter style={[styles.mt2, styles.pt2]}> | ||
<View style={[styles.mh5, styles.mb4]}> | ||
<TwoFactorAuthForm | ||
innerRef={formRef} | ||
validateInsteadOfDisable={false} | ||
/> | ||
</View> | ||
<Button | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, it should have bottom margin. I think we can leave this as it is as all of the page for 2FA flow does not have this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, OK. We should maybe make a followup GH issue to have someone fix that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I can fix that. |
||
success | ||
large | ||
text={translate('twoFactorAuth.disable')} | ||
isLoading={account?.isLoading} | ||
onPress={() => { | ||
if (!formRef.current) { | ||
return; | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
formRef.current.validateAndSubmitForm(); | ||
}} | ||
/> | ||
</FixedFooter> | ||
</StepWrapper> | ||
); | ||
} | ||
|
||
GetCode.displayName = 'GetCode'; | ||
|
||
export default withOnyx<GetCodeProps, BaseTwoFactorAuthFormOnyxProps>({ | ||
account: {key: ONYXKEYS.ACCOUNT}, | ||
user: { | ||
key: ONYXKEYS.USER, | ||
}, | ||
})(GetCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldEnableKeyboardAvoidingView
caused an issue here. where code input was left behind keyboard