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

Navigate to the profile/account when the user cancel re-authen during the change pw process #1940

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 12 additions & 4 deletions src/components/Dashboard/AuthenticateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { authenticate } from "apis/eduidAuthn";
import NotificationModal from "components/Common/NotificationModal";
import { useAppDispatch, useAppSelector } from "eduid-hooks";
import { FormattedMessage } from "react-intl";
import { useNavigate } from "react-router-dom";
import authnSlice from "slices/Authn";
import { clearNotifications } from "slices/Notifications";

Expand All @@ -10,6 +11,7 @@ export function AuthenticateModal() {
const re_authenticate = useAppSelector((state) => state.authn.re_authenticate);
const frontend_action = useAppSelector((state) => state.authn.frontend_action);
const frontend_state = useAppSelector((state) => state.authn.frontend_state);
const navigate = useNavigate();

async function handleAuthenticate() {
dispatch(authnSlice.actions.setReAuthenticate(false));
Expand All @@ -21,6 +23,15 @@ export function AuthenticateModal() {
}
}

function handleCloseModal() {
// navigate to account when user cancel re-authentication
if (frontend_action === "changepwAuthn" && re_authenticate) {
navigate("profile/account/");
}
dispatch(authnSlice.actions.setAuthnFrontendReset());
dispatch(authnSlice.actions.setReAuthenticate(false));
}

return (
<NotificationModal
id="security-confirm-modal"
Expand All @@ -32,10 +43,7 @@ export function AuthenticateModal() {
/>
}
showModal={re_authenticate}
closeModal={() => {
dispatch(authnSlice.actions.setAuthnFrontendReset());
dispatch(authnSlice.actions.setReAuthenticate(false));
}}
closeModal={handleCloseModal}
acceptModal={handleAuthenticate}
acceptButtonText={<FormattedMessage defaultMessage="Continue" description="continue button" />}
/>
Expand Down
1 change: 1 addition & 0 deletions src/components/Dashboard/ChangePassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function ChangePassword() {
const dispatch = useAppDispatch();
const intl = useIntl();
const suggested = useAppSelector((state) => state.chpass.suggested_password);
const re_authenticate = useAppSelector((state) => state.authn.re_authenticate);
const [renderSuggested, setRenderSuggested] = useState(true); // toggle display of custom or suggested password forms
const navigate = useNavigate();
let isMounted = true;
Expand Down
1 change: 1 addition & 0 deletions src/components/Dashboard/ChangePasswordDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function ChangePasswordDisplay() {
async function handleSuggestedPassword() {
const response = await dispatch(fetchSuggestedPassword());
if (fetchSuggestedPassword.fulfilled.match(response)) {
console.log("response", response);
navigate("/profile/chpass");
}
}
Expand Down
Loading