Skip to content
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: email is not shown in authenticator app #28164

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/pages/settings/Security/TwoFactorAuth/Steps/VerifyStep.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useEffect} from 'react';
import {withOnyx} from 'react-native-onyx';
import {ScrollView, View} from 'react-native';
import PropTypes from 'prop-types';
import * as Session from '../../../../../libs/actions/Session';
import styles from '../../../../../styles/styles';
import Button from '../../../../../components/Button';
Expand All @@ -22,7 +23,14 @@ import {defaultAccount, TwoFactorAuthPropTypes} from '../TwoFactorAuthPropTypes'

const TROUBLESHOOTING_LINK = 'https://community.expensify.com/discussion/7736/faq-troubleshooting-two-factor-authentication-issues/p1?new=1';

function VerifyStep({account = defaultAccount}) {
const defaultProps = {
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
account: defaultAccount,
session: {
email: null,
},
};

function VerifyStep({account, session}) {
const {translate} = useLocalize();

const formRef = React.useRef(null);
Expand Down Expand Up @@ -61,7 +69,7 @@ function VerifyStep({account = defaultAccount}) {
* @returns {string}
*/
function buildAuthenticatorUrl() {
return `otpauth://totp/Expensify:${account.primaryLogin}?secret=${account.twoFactorAuthSecretKey}&issuer=Expensify`;
return `otpauth://totp/Expensify:${account.primaryLogin || session.email}?secret=${account.twoFactorAuthSecretKey}&issuer=Expensify`;
}

return (
Expand Down Expand Up @@ -128,9 +136,20 @@ function VerifyStep({account = defaultAccount}) {
);
}

VerifyStep.propTypes = TwoFactorAuthPropTypes;
VerifyStep.propTypes = {
/** Information about the users account that is logging in */
account: TwoFactorAuthPropTypes.account,

/** Session of currently logged in user */
session: PropTypes.shape({
/** Email address */
email: PropTypes.string.isRequired,
}),
};
VerifyStep.defaultProps = defaultProps;

// eslint-disable-next-line rulesdir/onyx-props-must-have-default
export default withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
session: {key: ONYXKEYS.SESSION},
})(VerifyStep);
Loading