-
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
fix: 2FA bug fixes #19260
fix: 2FA bug fixes #19260
Changes from all commits
bf1cc35
9a8ec11
6a3ec66
96e49c3
93936a2
eaf3059
d92dabc
4da2f31
d205df2
bd39be1
16a9656
c7e295f
7da13b0
1ee87e7
931c335
48a90a9
023e5d9
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 |
---|---|---|
|
@@ -117,20 +117,21 @@ class ValidateLoginPage extends Component { | |
} | ||
|
||
render() { | ||
const isTfaRequired = lodashGet(this.props, 'account.requiresTwoFactorAuth', false); | ||
const is2FARequired = lodashGet(this.props, 'account.requiresTwoFactorAuth', false); | ||
const isSignedIn = Boolean(lodashGet(this.props, 'session.authToken', null)); | ||
const currentAuthState = this.getAutoAuthState(); | ||
return ( | ||
<> | ||
{this.getAutoAuthState() === CONST.AUTO_AUTH_STATE.FAILED && <ExpiredValidateCodeModal />} | ||
{this.getAutoAuthState() === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && (!isTfaRequired || isSignedIn) && <AbracadabraModal />} | ||
{this.getAutoAuthState() === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && isTfaRequired && !isSignedIn && <TfaRequiredModal />} | ||
{this.getAutoAuthState() === CONST.AUTO_AUTH_STATE.NOT_STARTED && ( | ||
{currentAuthState === CONST.AUTO_AUTH_STATE.FAILED && <ExpiredValidateCodeModal />} | ||
{currentAuthState === CONST.AUTO_AUTH_STATE.JUST_SIGNED_IN && is2FARequired && !isSignedIn && <TfaRequiredModal />} | ||
{currentAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && isSignedIn && <AbracadabraModal />} | ||
{currentAuthState === CONST.AUTO_AUTH_STATE.NOT_STARTED && !isSignedIn && ( | ||
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. @BeeMargarida Do you remember why we had to add the 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. @s77rt Yes, it came from this commit to fix this bug mentioned in this slack thread. Before, it was necessary because the check for 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. @BeeMargarida Thank you! |
||
<ValidateCodeModal | ||
accountID={this.getAccountID()} | ||
code={this.getValidateCode()} | ||
/> | ||
)} | ||
{this.getAutoAuthState() === CONST.AUTO_AUTH_STATE.SIGNING_IN && <FullScreenLoadingIndicator />} | ||
{currentAuthState === CONST.AUTO_AUTH_STATE.SIGNING_IN && <FullScreenLoadingIndicator />} | ||
</> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {ActivityIndicator, View} from 'react-native'; | ||
import {ScrollView} from 'react-native-gesture-handler'; | ||
import _ from 'underscore'; | ||
import PropTypes from 'prop-types'; | ||
import HeaderWithCloseButton from '../../../../components/HeaderWithCloseButton'; | ||
|
@@ -11,6 +12,7 @@ import compose from '../../../../libs/compose'; | |
import ROUTES from '../../../../ROUTES'; | ||
import FullPageOfflineBlockingView from '../../../../components/BlockingViews/FullPageOfflineBlockingView'; | ||
import * as Illustrations from '../../../../components/Icon/Illustrations'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions'; | ||
import styles from '../../../../styles/styles'; | ||
import FixedFooter from '../../../../components/FixedFooter'; | ||
import Button from '../../../../components/Button'; | ||
|
@@ -24,6 +26,7 @@ import * as TwoFactorAuthActions from '../../../../libs/actions/TwoFactorAuthAct | |
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
...windowDimensionsPropTypes, | ||
account: PropTypes.shape({ | ||
/** User recovery codes for setting up 2-FA */ | ||
recoveryCodes: PropTypes.string, | ||
|
@@ -64,65 +67,67 @@ function CodesPage(props) { | |
onCloseButtonPress={() => Navigation.dismissModal(true)} | ||
/> | ||
<FullPageOfflineBlockingView> | ||
<Section | ||
title={props.translate('twoFactorAuth.keepCodesSafe')} | ||
icon={Illustrations.ShieldYellow} | ||
containerStyles={[styles.twoFactorAuthSection]} | ||
iconContainerStyles={[styles.ml6]} | ||
> | ||
<View style={styles.mv3}> | ||
<Text>{props.translate('twoFactorAuth.codesLoseAccess')}</Text> | ||
</View> | ||
<View style={styles.twoFactorAuthCodesBox}> | ||
{props.account.isLoading ? ( | ||
<View style={styles.twoFactorLoadingContainer}> | ||
<ActivityIndicator color={themeColors.spinner} /> | ||
</View> | ||
) : ( | ||
<> | ||
<View style={styles.twoFactorAuthCodesContainer}> | ||
{Boolean(props.account.recoveryCodes) && | ||
_.map(props.account.recoveryCodes.split(', '), (code) => ( | ||
<Text | ||
style={styles.twoFactorAuthCode} | ||
key={code} | ||
> | ||
{code} | ||
</Text> | ||
))} | ||
<ScrollView contentContainerStyle={styles.flex1}> | ||
<Section | ||
title={props.translate('twoFactorAuth.keepCodesSafe')} | ||
icon={Illustrations.ShieldYellow} | ||
containerStyles={[styles.twoFactorAuthSection]} | ||
iconContainerStyles={[styles.ml6]} | ||
> | ||
<View style={styles.mv3}> | ||
<Text>{props.translate('twoFactorAuth.codesLoseAccess')}</Text> | ||
</View> | ||
<View style={[styles.twoFactorAuthCodesBox(props)]}> | ||
{props.account.isLoading ? ( | ||
<View style={styles.twoFactorLoadingContainer}> | ||
<ActivityIndicator color={themeColors.spinner} /> | ||
</View> | ||
<View style={styles.twoFactorAuthCodesButtonsContainer}> | ||
<Button | ||
text={props.translate('twoFactorAuth.copyCodes')} | ||
medium | ||
onPress={() => { | ||
Clipboard.setString(props.account.recoveryCodes); | ||
setIsNextButtonDisabled(false); | ||
}} | ||
style={styles.twoFactorAuthCodesButton} | ||
/> | ||
<Button | ||
text="Download" | ||
medium | ||
onPress={() => { | ||
localFileDownload('two-factor-auth-codes', props.account.recoveryCodes); | ||
setIsNextButtonDisabled(false); | ||
}} | ||
style={styles.twoFactorAuthCodesButton} | ||
/> | ||
</View> | ||
</> | ||
)} | ||
</View> | ||
</Section> | ||
<FixedFooter style={[styles.twoFactorAuthFooter]}> | ||
<Button | ||
success | ||
text={props.translate('common.next')} | ||
onPress={() => Navigation.navigate(ROUTES.SETTINGS_2FA_VERIFY)} | ||
isDisabled={isNextButtonDisabled} | ||
/> | ||
</FixedFooter> | ||
) : ( | ||
<> | ||
<View style={styles.twoFactorAuthCodesContainer}> | ||
{Boolean(props.account.recoveryCodes) && | ||
_.map(props.account.recoveryCodes.split(', '), (code) => ( | ||
<Text | ||
style={styles.twoFactorAuthCode} | ||
key={code} | ||
> | ||
{code} | ||
</Text> | ||
))} | ||
</View> | ||
<View style={styles.twoFactorAuthCodesButtonsContainer}> | ||
<Button | ||
text={props.translate('twoFactorAuth.copyCodes')} | ||
medium | ||
onPress={() => { | ||
Clipboard.setString(props.account.recoveryCodes); | ||
setIsNextButtonDisabled(false); | ||
}} | ||
style={styles.twoFactorAuthCodesButton} | ||
/> | ||
<Button | ||
text={props.translate('common.download')} | ||
medium | ||
onPress={() => { | ||
localFileDownload('two-factor-auth-codes', props.account.recoveryCodes); | ||
setIsNextButtonDisabled(false); | ||
}} | ||
style={styles.twoFactorAuthCodesButton} | ||
/> | ||
</View> | ||
</> | ||
)} | ||
</View> | ||
</Section> | ||
<FixedFooter style={[styles.twoFactorAuthFooter]}> | ||
<Button | ||
success | ||
text={props.translate('common.next')} | ||
onPress={() => Navigation.navigate(ROUTES.SETTINGS_2FA_VERIFY)} | ||
isDisabled={isNextButtonDisabled} | ||
/> | ||
</FixedFooter> | ||
Comment on lines
+122
to
+129
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. Seems we accidentally included FixedFooter inside scroll containers and that led to this regression #20138 |
||
</ScrollView> | ||
</FullPageOfflineBlockingView> | ||
</ScreenWrapper> | ||
); | ||
|
@@ -133,6 +138,7 @@ CodesPage.defaultProps = defaultProps; | |
|
||
export default compose( | ||
withLocalize, | ||
withWindowDimensions, | ||
withOnyx({ | ||
account: {key: ONYXKEYS.ACCOUNT}, | ||
}), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2127,14 +2127,26 @@ const styles = { | |
padding: 0, | ||
}, | ||
|
||
twoFactorAuthCodesBox: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: themeColors.highlightBG, | ||
paddingVertical: 28, | ||
paddingHorizontal: 60, | ||
borderRadius: 16, | ||
marginTop: 32, | ||
twoFactorAuthCodesBox: ({isExtraSmallScreenWidth, isSmallScreenWidth}) => { | ||
let paddingHorizontal = styles.ph15; | ||
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. @shawnborton buddy check please for these new style 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. What exactly am I reviewing here? Just the screenshots from the first comment? 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. sorry, Nothing has changed much in the view. I wanted to get an eye on padding prooerty we added to support view for extra small devices. 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. Ah got it. Can you show me screenshots of what this looks like in practice please? Thanks! 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. @shawnborton Here you go: 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. Okay cool, that works for me! 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. Thanks shawn! |
||
|
||
if (isSmallScreenWidth) { | ||
paddingHorizontal = styles.ph10; | ||
} | ||
|
||
if (isExtraSmallScreenWidth) { | ||
paddingHorizontal = styles.ph4; | ||
} | ||
|
||
return { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: themeColors.highlightBG, | ||
paddingVertical: 28, | ||
borderRadius: 16, | ||
marginTop: 32, | ||
...paddingHorizontal, | ||
}; | ||
}, | ||
|
||
twoFactorLoadingContainer: { | ||
|
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.
Thanks! Is this file really needed?
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.
I just merged
main
and installed dependencies. I guess in some other PR the dependencies were updated but the lockfile wasn't pushed