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/19496 2fa steps refactor #23060

Merged
merged 36 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
498d5c7
refactor: wip - 2fa steps
koko57 Jul 14, 2023
24e914a
refactor: wip - remove 2fa pages
koko57 Jul 15, 2023
5baaf08
refactor: final changes
koko57 Jul 17, 2023
7a9162a
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Jul 17, 2023
2478625
fix: redirect to isenabled step instead back to settings
koko57 Jul 18, 2023
9b6f5dd
fix: remove unnecessary object
koko57 Jul 18, 2023
e5b0cc0
refactor: use context
koko57 Jul 18, 2023
caab005
fix: wip -apply requested changes
koko57 Jul 18, 2023
8c63763
fix: apply requested changes
koko57 Jul 18, 2023
357b6b5
fix: change double bangs for boolean
koko57 Jul 18, 2023
431c979
fix: run prettier
koko57 Jul 19, 2023
f2bfffa
fix: resolve conflicts
koko57 Jul 19, 2023
e3655df
fix: rename 2fa steps
koko57 Jul 26, 2023
becc443
fix: apply requested changes
koko57 Jul 26, 2023
48da39d
fix: fix linting error
koko57 Jul 26, 2023
27ac425
refactor: rename components for consistency
koko57 Jul 26, 2023
dbfec6e
fix: resolve conflicts
koko57 Jul 27, 2023
57dd06b
fix: resolve conflicts
koko57 Aug 2, 2023
cfd4f62
fix: fix linter issue
koko57 Aug 2, 2023
5a4f42d
fix: resolve conflicts
koko57 Aug 3, 2023
a95d9a7
fix: resolve conflicts
koko57 Aug 4, 2023
ae18cec
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Aug 6, 2023
49ab183
fix: fix typo and add proptypes comments
koko57 Aug 6, 2023
191b0c3
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Aug 9, 2023
73bd246
fix: resolve conflicts
koko57 Aug 11, 2023
772580a
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Aug 14, 2023
abdd224
fix: resolve conflicts
koko57 Aug 16, 2023
e522841
fix: restore changes for code page
koko57 Aug 16, 2023
1162131
fix: fix styles prop error
koko57 Aug 16, 2023
b674139
fix: focus input on animation end
koko57 Aug 16, 2023
591c666
fix: fix animation direction
koko57 Aug 16, 2023
065503a
fix: remove duplicated file
koko57 Aug 16, 2023
2cebedb
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Aug 17, 2023
d69dd90
Merge branch 'main' into fix/19496-2fa-steps-refactor
koko57 Aug 17, 2023
660aa2a
fix: fix lint
koko57 Aug 17, 2023
30ca6de
fix: prettier
koko57 Aug 17, 2023
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
7 changes: 7 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -2536,6 +2536,13 @@ const CONST = {
TRANSLATION_KEYS: {
ATTACHMENT: 'common.attachment',
},
TWO_FACTOR_AUTH_STEPS: {
CODES: 'CODES',
VERIFY: 'VERIFY',
SUCCESS: 'SUCCESS',
IS_ENABLED: 'IS_ENABLED',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there reason why this name cannot just be ENABLED?

DISABLE: 'DISABLE',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then change this to DISABLED to be consistent with ENABLED

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aimane-chnaif Should I also change the components' (steps) names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes to be consistent

}
};

export default CONST;
6 changes: 1 addition & 5 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ export default {
SETTINGS_CONTACT_METHOD_DETAILS: `${SETTINGS_CONTACT_METHODS}/:contactMethod/details`,
getEditContactMethodRoute: (contactMethod) => `${SETTINGS_CONTACT_METHODS}/${encodeURIComponent(contactMethod)}/details`,
SETTINGS_NEW_CONTACT_METHOD: `${SETTINGS_CONTACT_METHODS}/new`,
SETTINGS_2FA_IS_ENABLED: 'settings/security/two-factor-auth/enabled',
SETTINGS_2FA_DISABLE: 'settings/security/two-factor-auth/disable',
SETTINGS_2FA_CODES: 'settings/security/two-factor-auth/codes',
SETTINGS_2FA_VERIFY: 'settings/security/two-factor-auth/verify',
SETTINGS_2FA_SUCCESS: 'settings/security/two-factor-auth/success',
SETTINGS_2FA: 'settings/security/two-factor-auth',
NEW_GROUP: 'new/group',
NEW_CHAT: 'new/chat',
NEW_TASK,
Expand Down
32 changes: 2 additions & 30 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,38 +623,10 @@ const SettingsModalStackNavigator = createModalStackNavigator([
},
{
getComponent: () => {
const SettingsTwoFactorAuthIsEnabled = require('../../../pages/settings/Security/TwoFactorAuth/IsEnabledPage').default;
return SettingsTwoFactorAuthIsEnabled;
},
name: 'Settings_TwoFactorAuthIsEnabled',
},
{
getComponent: () => {
const SettingsTwoFactorAuthDisable = require('../../../pages/settings/Security/TwoFactorAuth/DisablePage').default;
return SettingsTwoFactorAuthDisable;
},
name: 'Settings_TwoFactorAuthDisable',
},
{
getComponent: () => {
const SettingsTwoFactorAuthCodes = require('../../../pages/settings/Security/TwoFactorAuth/CodesPage').default;
const SettingsTwoFactorAuthCodes = require('../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default;
koko57 marked this conversation as resolved.
Show resolved Hide resolved
return SettingsTwoFactorAuthCodes;
},
name: 'Settings_TwoFactorAuthCodes',
},
{
getComponent: () => {
const SettingsTwoFactorAuthVerify = require('../../../pages/settings/Security/TwoFactorAuth/VerifyPage').default;
return SettingsTwoFactorAuthVerify;
},
name: 'Settings_TwoFactorAuthVerify',
},
{
getComponent: () => {
const SettingsTwoFactorAuthSuccess = require('../../../pages/settings/Security/TwoFactorAuth/SuccessPage').default;
return SettingsTwoFactorAuthSuccess;
},
name: 'Settings_TwoFactorAuthSuccess',
name: 'Settings_TwoFactorAuth',
},
]);

Expand Down
20 changes: 2 additions & 18 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,8 @@ export default {
path: ROUTES.SETTINGS_PERSONAL_DETAILS_ADDRESS,
exact: true,
},
Settings_TwoFactorAuthIsEnabled: {
path: ROUTES.SETTINGS_2FA_IS_ENABLED,
exact: true,
},
Settings_TwoFactorAuthDisable: {
path: ROUTES.SETTINGS_2FA_DISABLE,
exact: true,
},
Settings_TwoFactorAuthCodes: {
path: ROUTES.SETTINGS_2FA_CODES,
exact: true,
},
Settings_TwoFactorAuthVerify: {
path: ROUTES.SETTINGS_2FA_VERIFY,
exact: true,
},
Settings_TwoFactorAuthSuccess: {
path: ROUTES.SETTINGS_2FA_SUCCESS,
Settings_TwoFactorAuth: {
path: ROUTES.SETTINGS_2FA,
exact: true,
},
Settings_Share_Code: {
Expand Down
16 changes: 14 additions & 2 deletions src/libs/actions/TwoFactorAuthActions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../../ONYXKEYS';
import Navigation from "../Navigation/Navigation";
import ROUTES from "../../ROUTES";

/**
* Clear 2FA data if the flow is interrupted without finishing
*/
function clearTwoFactorAuthData() {
Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: '', twoFactorAuthSecretKey: ''});
Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: '', twoFactorAuthSecretKey: '', twoFactorAuthStep: ''});
}

function setTwoFactorAuthStep(twoFactorAuthStep) {
Onyx.merge(ONYXKEYS.ACCOUNT, {twoFactorAuthStep});
}

function quitAndNavigateBackToSettings() {
clearTwoFactorAuthData();
Navigation.goBack(ROUTES.SETTINGS_SECURITY);
}

export {
// eslint-disable-next-line import/prefer-default-export
clearTwoFactorAuthData,
setTwoFactorAuthStep,
quitAndNavigateBackToSettings,
};
9 changes: 1 addition & 8 deletions src/pages/settings/Security/SecuritySettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ function SecuritySettingsPage(props) {
{
translationKey: 'twoFactorAuth.headerTitle',
icon: Expensicons.Shield,
action: () => {
if (props.account.requiresTwoFactorAuth) {
Navigation.navigate(ROUTES.SETTINGS_2FA_IS_ENABLED);
} else {
Session.toggleTwoFactorAuth(true);
Navigation.navigate(ROUTES.SETTINGS_2FA_CODES);
}
},
action: () => Navigation.navigate(ROUTES.SETTINGS_2FA)
},
{
translationKey: 'passwordPage.changePassword',
Expand Down
150 changes: 0 additions & 150 deletions src/pages/settings/Security/TwoFactorAuth/CodesPage.js

This file was deleted.

57 changes: 0 additions & 57 deletions src/pages/settings/Security/TwoFactorAuth/DisablePage.js

This file was deleted.

Loading