Skip to content

Commit

Permalink
Update password dialog for account modification actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Sep 23, 2024
1 parent 8ec1036 commit f2d58eb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function LoginPasswordModal({
key={"password"}
style={{ display: "flex", flexDirection: "column" }}
>
{t("LOG_IN_PASSWORD_PROMPT")}
{acquisitionSession.purpose == "login"
? t("LOG_IN_PASSWORD_PROMPT")
: t("CONFIRM_PASSWORD_PROMPT")}
<VerticalSpacer height={3} />
<LineEdit
password={true}
Expand Down Expand Up @@ -58,18 +60,27 @@ export function LoginPasswordModal({

return (
<Modal
heading={t("LOG_IN_PASSWORD_TITLE", {
username: acquisitionSession.username,
})}
heading={
acquisitionSession.purpose == "login"
? t("LOG_IN_PASSWORD_TITLE", {
username: acquisitionSession.username,
})
: t("CONFIRM_PASSWORD")
}
buttons={[
{
text: t("BACK"),
onClick: () => acquisitionSession.quit(),
},
{
text: t("FORGOT_PASSWORD"),
onClick: () => acquisitionSession.triggerPasswordReset(),
},
...(acquisitionSession.purpose == "login"
? [
{
text: t("FORGOT_PASSWORD"),
onClick: () =>
acquisitionSession.triggerPasswordReset(),
},
]
: []),
{
text: t("NEXT"),
onClick: () => {
Expand Down

This file was deleted.

14 changes: 9 additions & 5 deletions Parlance.ClientApp/src/helpers/TokenAcquisitionSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { decode, encode } from "@/helpers/Base64";
import { PasswordResetModal } from "@/components/modals/account/resets/PasswordResetModal";

export class TokenAcquisitionSession {
private readonly purpose: TokenPurpose;
private readonly _purpose: TokenPurpose;
private readonly _username: string;
private readonly _prePassword: string;
private _availableLoginTypes: LoginType[] = [];
Expand All @@ -39,11 +39,15 @@ export class TokenAcquisitionSession {
) {
this._username = username;
this._prePassword = prePassword;
this.purpose = purpose;
this._purpose = purpose;
this._successFunction = successFunction;
this._failureFunction = failureFunction;
}

get purpose() {
return this._purpose;
}

get prePassword() {
return this._prePassword;
}
Expand All @@ -53,7 +57,7 @@ export class TokenAcquisitionSession {
"/api/user/tokentypes",
{
username: this._username,
purpose: this.purpose,
purpose: this._purpose,
},
);
}
Expand All @@ -69,7 +73,7 @@ export class TokenAcquisitionSession {
{
...this.loginSessionDetails,
username: this._username,
purpose: this.purpose,
purpose: this._purpose,
},
);
Modal.unmount();
Expand All @@ -79,7 +83,7 @@ export class TokenAcquisitionSession {
!fido2Details &&
window.PublicKeyCredential &&
!localStorage.getItem("passkey-advertisement-never-ask") &&
this.purpose == "login"
this._purpose == "login"
) {
Modal.mount(
<RegisterSecurityKeyAdvertisement
Expand Down
1 change: 0 additions & 1 deletion Parlance.ClientApp/src/pages/Account/EmailChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
import SelectableList from "../../components/SelectableList";
import { VerticalLayout, VerticalSpacer } from "@/components/Layouts";
import { useState } from "react";
import PasswordConfirmModal from "../../components/modals/account/PasswordConfirmModal";
import Modal from "../../components/Modal";
import Fetch from "../../helpers/Fetch";
import LoadingModal from "../../components/modals/LoadingModal";
Expand Down
1 change: 0 additions & 1 deletion Parlance.ClientApp/src/pages/Account/Otp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React, {
ForwardedRef,
} from "react";
import Modal from "../../components/Modal";
import PasswordConfirmModal from "../../components/modals/account/PasswordConfirmModal";
import Fetch from "../../helpers/Fetch";
import Styles from "./Otp.module.css";
import QRCode from "react-qr-code";
Expand Down
1 change: 0 additions & 1 deletion Parlance.ClientApp/src/pages/Account/PasswordChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
import SelectableList from "../../components/SelectableList";
import { VerticalLayout, VerticalSpacer } from "@/components/Layouts";
import { useState } from "react";
import PasswordConfirmModal from "../../components/modals/account/PasswordConfirmModal";
import Modal from "../../components/Modal";
import Fetch from "../../helpers/Fetch";
import LoadingModal from "../../components/modals/LoadingModal";
Expand Down
1 change: 0 additions & 1 deletion Parlance.ClientApp/src/pages/Account/SecurityKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useNavigate } from "react-router-dom";
import React, { useEffect, useState, useContext, ReactNode } from "react";
import { useTranslation } from "react-i18next";
import Modal from "../../components/Modal";
import PasswordConfirmModal from "../../components/modals/account/PasswordConfirmModal";
import LoadingModal from "../../components/modals/LoadingModal";
import Fetch from "../../helpers/Fetch";
import ErrorModal from "../../components/modals/ErrorModal";
Expand Down
1 change: 0 additions & 1 deletion Parlance.ClientApp/src/pages/Account/UsernameChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useTranslation } from "react-i18next";
import SelectableList from "../../components/SelectableList";
import { VerticalLayout, VerticalSpacer } from "@/components/Layouts";
import { useState } from "react";
import PasswordConfirmModal from "../../components/modals/account/PasswordConfirmModal";
import Modal from "../../components/Modal";
import Fetch from "../../helpers/Fetch";
import LoadingModal from "../../components/modals/LoadingModal";
Expand Down

0 comments on commit f2d58eb

Please sign in to comment.