diff --git a/src/base-container/index.jsx b/src/base-container/index.jsx
index f42305ca..8c46ad42 100644
--- a/src/base-container/index.jsx
+++ b/src/base-container/index.jsx
@@ -1,10 +1,12 @@
import React from 'react';
+import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { ModalDialog } from '@openedx/paragon';
import classNames from 'classnames';
import PropTypes from 'prop-types';
-import { useDispatch } from '../data/storeHooks';
+import { FORGOT_PASSWORD_FORM } from '../data/constants';
+import { useDispatch, useSelector } from '../data/storeHooks';
import { deleteQueryParams } from '../data/utils';
import { loginErrorClear } from '../forms/login-popup/data/reducers';
import { clearAllRegistrationErrors } from '../forms/registration-popup/data/reducers';
@@ -28,10 +30,17 @@ const BaseContainer = ({
hasCloseButton = true,
isOpen,
size = 'lg',
+ currentForm,
}) => {
const dispatch = useDispatch();
+ const authenticatedUser = getAuthenticatedUser();
+ const loginErrorResult = useSelector(state => state.login.loginError);
+
const handleOnClose = () => {
+ if (authenticatedUser && loginErrorResult.redirectUrl && currentForm === FORGOT_PASSWORD_FORM) {
+ window.location.href = loginErrorResult.redirectUrl;
+ }
deleteQueryParams(['authMode', 'tpa_hint', 'password_reset_token', 'track']);
dispatch(forgotPasswordClearStatus());
dispatch(loginErrorClear());
@@ -70,6 +79,7 @@ BaseContainer.propTypes = {
close: PropTypes.func.isRequired,
size: PropTypes.string,
hasCloseButton: PropTypes.bool,
+ currentForm: PropTypes.string.isRequired,
};
export default BaseContainer;
diff --git a/src/forms/login-popup/data/reducers.js b/src/forms/login-popup/data/reducers.js
index 2407221c..22226c15 100644
--- a/src/forms/login-popup/data/reducers.js
+++ b/src/forms/login-popup/data/reducers.js
@@ -53,10 +53,11 @@ export const loginSlice = createSlice({
errorCode,
email,
value,
+ redirectUrl,
} = payload;
const errorContext = { ...context, email, errorMessage: value };
- state.loginError = { errorCode, errorContext };
+ state.loginError = { errorCode, errorContext, redirectUrl };
state.loginResult = {};
state.submitState = FAILURE_STATE;
},
diff --git a/src/forms/reset-password-popup/forgot-password/index.jsx b/src/forms/reset-password-popup/forgot-password/index.jsx
index 9bce7c8b..ac1458f7 100644
--- a/src/forms/reset-password-popup/forgot-password/index.jsx
+++ b/src/forms/reset-password-popup/forgot-password/index.jsx
@@ -1,6 +1,7 @@
import React, { useEffect, useRef, useState } from 'react';
import { getConfig } from '@edx/frontend-platform';
+import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Button, Container, Form, StatefulButton,
@@ -26,6 +27,8 @@ const ForgotPasswordForm = () => {
const { formatMessage } = useIntl();
const dispatch = useDispatch();
+ const authenticatedUser = getAuthenticatedUser();
+
const status = useSelector(state => state.forgotPassword?.status);
const backedUpFormData = useSelector(state => state.forgotPassword?.forgotPasswordFormData);
const loginErrorCode = useSelector(state => state.login.loginError?.errorCode);
@@ -168,7 +171,7 @@ const ForgotPasswordForm = () => {