mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Allow background to handle forgotten password flow (#17501)
This commit is contained in:
parent
33ee1e4f8c
commit
3f50243cef
@ -4209,6 +4209,8 @@ export default class MetamaskController extends EventEmitter {
|
||||
};
|
||||
});
|
||||
|
||||
this.unMarkPasswordForgotten();
|
||||
|
||||
// In the current implementation, this handler is triggered by a
|
||||
// KeyringController event. Other controllers subscribe to the 'unlock'
|
||||
// event of the MetaMaskController itself.
|
||||
|
@ -146,12 +146,6 @@ export default function reduceApp(state = {}, action) {
|
||||
accountDetail: {},
|
||||
};
|
||||
|
||||
case actionConstants.FORGOT_PASSWORD:
|
||||
return {
|
||||
...appState,
|
||||
forgottenPassword: action.value,
|
||||
};
|
||||
|
||||
case actionConstants.SHOW_SEND_TOKEN_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
@ -180,9 +174,6 @@ export default function reduceApp(state = {}, action) {
|
||||
case actionConstants.SHOW_ACCOUNT_DETAIL:
|
||||
return {
|
||||
...appState,
|
||||
forgottenPassword: appState.forgottenPassword
|
||||
? !appState.forgottenPassword
|
||||
: null,
|
||||
accountDetail: {
|
||||
subview: 'transactions',
|
||||
accountExport: 'none',
|
||||
@ -196,7 +187,6 @@ export default function reduceApp(state = {}, action) {
|
||||
isLoading: false,
|
||||
warning: null,
|
||||
scrollToBottom: false,
|
||||
forgottenPassword: false,
|
||||
};
|
||||
|
||||
case actionConstants.SHOW_CONF_TX_PAGE:
|
||||
|
@ -132,7 +132,6 @@ describe('App State', () => {
|
||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
||||
value: 'context address',
|
||||
});
|
||||
expect(state.forgottenPassword).toBeNull(); // default
|
||||
expect(state.accountDetail.subview).toStrictEqual('transactions'); // default
|
||||
expect(state.accountDetail.accountExport).toStrictEqual('none'); // default
|
||||
expect(state.accountDetail.privateKey).toStrictEqual(''); // default
|
||||
@ -163,7 +162,6 @@ describe('App State', () => {
|
||||
expect(state.isLoading).toStrictEqual(false);
|
||||
expect(state.warning).toBeNull();
|
||||
expect(state.scrollToBottom).toStrictEqual(false);
|
||||
expect(state.forgottenPassword).toStrictEqual(false);
|
||||
});
|
||||
|
||||
it('shows confirm tx page', () => {
|
||||
|
@ -76,7 +76,7 @@ const mapStateToProps = (state) => {
|
||||
firstTimeFlowType,
|
||||
completedOnboarding,
|
||||
} = metamask;
|
||||
const { forgottenPassword } = appState;
|
||||
const { forgottenPassword } = metamask;
|
||||
const totalUnapprovedCount = getTotalUnapprovedCount(state);
|
||||
const swapsEnabled = getSwapsFeatureIsLive(state);
|
||||
const pendingConfirmations = getUnapprovedTemplatedConfirmations(state);
|
||||
|
@ -9,7 +9,6 @@ import {
|
||||
} from '../../helpers/constants/routes';
|
||||
import {
|
||||
tryUnlockMetamask,
|
||||
forgotPassword,
|
||||
markPasswordForgotten,
|
||||
forceUpdateMetamaskState,
|
||||
showModal,
|
||||
@ -27,7 +26,6 @@ const mapStateToProps = (state) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
forgotPassword: () => dispatch(forgotPassword()),
|
||||
tryUnlockMetamask: (password) => dispatch(tryUnlockMetamask(password)),
|
||||
markPasswordForgotten: () => dispatch(markPasswordForgotten()),
|
||||
forceUpdateMetamaskState: () => forceUpdateMetamaskState(dispatch),
|
||||
|
@ -17,7 +17,6 @@ export const ACCOUNT_CHANGED = 'ACCOUNT_CHANGED';
|
||||
export const CHAIN_CHANGED = 'CHAIN_CHANGED';
|
||||
export const ADDRESS_BOOK_UPDATED = 'ADDRESS_BOOK_UPDATED';
|
||||
export const GAS_FEE_ESTIMATES_UPDATED = 'GAS_FEE_ESTIMATES_UPDATED';
|
||||
export const FORGOT_PASSWORD = 'FORGOT_PASSWORD';
|
||||
export const CLOSE_WELCOME_SCREEN = 'CLOSE_WELCOME_SCREEN';
|
||||
// unlock screen
|
||||
export const UNLOCK_IN_PROGRESS = 'UNLOCK_IN_PROGRESS';
|
||||
|
@ -1392,7 +1392,6 @@ export function markPasswordForgotten() {
|
||||
} finally {
|
||||
// TODO: handle errors
|
||||
dispatch(hideLoadingIndication());
|
||||
dispatch(forgotPassword());
|
||||
await forceUpdateMetamaskState(dispatch);
|
||||
}
|
||||
};
|
||||
@ -1402,20 +1401,12 @@ export function unMarkPasswordForgotten() {
|
||||
return (dispatch) => {
|
||||
return new Promise((resolve) => {
|
||||
callBackgroundMethod('unMarkPasswordForgotten', [], () => {
|
||||
dispatch(forgotPassword(false));
|
||||
resolve();
|
||||
});
|
||||
}).then(() => forceUpdateMetamaskState(dispatch));
|
||||
};
|
||||
}
|
||||
|
||||
export function forgotPassword(forgotPasswordState = true) {
|
||||
return {
|
||||
type: actionConstants.FORGOT_PASSWORD,
|
||||
value: forgotPasswordState,
|
||||
};
|
||||
}
|
||||
|
||||
export function closeWelcomeScreen() {
|
||||
return {
|
||||
type: actionConstants.CLOSE_WELCOME_SCREEN,
|
||||
|
@ -130,7 +130,6 @@ describe('Actions', () => {
|
||||
|
||||
const expectedActions = [
|
||||
{ type: 'SHOW_LOADING_INDICATION', value: undefined },
|
||||
{ type: 'FORGOT_PASSWORD', value: false },
|
||||
{
|
||||
type: 'UPDATE_METAMASK_STATE',
|
||||
value: baseMockState,
|
||||
@ -1674,11 +1673,6 @@ describe('Actions', () => {
|
||||
|
||||
await store.dispatch(actions.markPasswordForgotten());
|
||||
|
||||
const resultantActions = store.getActions();
|
||||
expect(resultantActions[1]).toStrictEqual({
|
||||
type: 'FORGOT_PASSWORD',
|
||||
value: true,
|
||||
});
|
||||
expect(background.markPasswordForgotten.callCount).toStrictEqual(1);
|
||||
});
|
||||
|
||||
@ -1693,7 +1687,6 @@ describe('Actions', () => {
|
||||
|
||||
const expectedActions = [
|
||||
{ type: 'HIDE_LOADING_INDICATION' },
|
||||
{ type: 'FORGOT_PASSWORD', value: true },
|
||||
{
|
||||
type: 'UPDATE_METAMASK_STATE',
|
||||
value: baseMockState,
|
||||
@ -1718,11 +1711,6 @@ describe('Actions', () => {
|
||||
|
||||
store.dispatch(actions.unMarkPasswordForgotten());
|
||||
|
||||
const resultantActions = store.getActions();
|
||||
expect(resultantActions[0]).toStrictEqual({
|
||||
type: 'FORGOT_PASSWORD',
|
||||
value: false,
|
||||
});
|
||||
expect(background.unMarkPasswordForgotten.callCount).toStrictEqual(1);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user