+
+
{ _t("Your password has been reset.") }
{ this.state.logoutDevices ?
{ _t(
"You have been logged out of all devices and will no longer receive " +
@@ -415,29 +352,38 @@ export default class ForgotPassword extends React.Component {
}
render() {
- let resetPasswordJsx;
+ let resetPasswordJsx: JSX.Element;
+
switch (this.state.phase) {
- case Phase.Forgot:
- resetPasswordJsx = this.renderForgot();
- break;
+ case Phase.EnterEmail:
case Phase.SendingEmail:
- resetPasswordJsx = this.renderSendingEmail();
+ resetPasswordJsx = this.renderEnterEmail();
break;
case Phase.EmailSent:
- resetPasswordJsx = this.renderEmailSent();
+ resetPasswordJsx = this.renderCheckEmail();
+ break;
+ case Phase.PasswordInput:
+ resetPasswordJsx = this.renderSetPassword();
+ break;
+ case Phase.ResettingPassword:
+ resetPasswordJsx = resetting password
;
break;
case Phase.Done:
resetPasswordJsx = this.renderDone();
break;
default:
- resetPasswordJsx =
;
+ // This should not happen. However, it is logged and the user is sent to the start.
+ logger.error(`unknown forgot passwort phase ${this.state.phase}`);
+ this.setState({
+ phase: Phase.EnterEmail,
+ });
+ return;
}
return (
- { _t('Set a new password') }
{ resetPasswordJsx }
diff --git a/src/components/structures/auth/forgot-password/CheckEmail.tsx b/src/components/structures/auth/forgot-password/CheckEmail.tsx
new file mode 100644
index 000000000000..5c67bfcb2315
--- /dev/null
+++ b/src/components/structures/auth/forgot-password/CheckEmail.tsx
@@ -0,0 +1,89 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import React, { useEffect, useRef, useState } from "react";
+
+import AccessibleButton from "../../../views/elements/AccessibleButton";
+import { Icon as EMailPromptIcon } from "../../../../../res/img/element-icons/email-prompt.svg";
+import { Icon as RetryIcon } from "../../../../../res/img/element-icons/retry.svg";
+import { _t } from '../../../../languageHandler';
+import Tooltip, { Alignment } from "../../../views/elements/Tooltip";
+
+interface CheckEmailProps {
+ email: string;
+ onResendClick: () => Promise;
+ onSubmitForm: (ev: React.FormEvent) => void;
+}
+
+/**
+ * This component renders the email verification view of the forgot password flow.
+ */
+export const CheckEmail: React.FC = ({
+ email,
+ onSubmitForm,
+ onResendClick,
+}) => {
+ const resentTooltipVisibleTimerId = useRef(null);
+ const [resentTooltipVisible, setResentTooltipVisible] = useState(false);
+
+ const onResendClickFn = async (): Promise => {
+ await onResendClick();
+ setResentTooltipVisible(true);
+ resentTooltipVisibleTimerId.current = setTimeout(() => setResentTooltipVisible(false), 2500);
+ };
+
+ useEffect(() => {
+ return () => {
+ if (resentTooltipVisibleTimerId.current) {
+ clearTimeout(resentTooltipVisibleTimerId.current);
+ }
+ };
+ });
+
+ return
+
+
{ _t("Check your email to continue") }
+
+ { _t(
+ "Follow the instructions sent to %(email)s",
+ { email: email },
+ { b: t => { t } },
+ ) }
+
+
+
{ _t("Did not receive it?") }
+
+
+ { _t("Resend") }
+
+
+
+
+
;
+};
diff --git a/src/components/structures/auth/forgot-password/EnterEmail.tsx b/src/components/structures/auth/forgot-password/EnterEmail.tsx
new file mode 100644
index 000000000000..6eef4275f00c
--- /dev/null
+++ b/src/components/structures/auth/forgot-password/EnterEmail.tsx
@@ -0,0 +1,96 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import React, { useRef } from "react";
+
+import { Icon as EMailIcon } from "../../../../../res/img/element-icons/Email-icon.svg";
+import { _t, _td } from '../../../../languageHandler';
+import EmailField from "../../../views/auth/EmailField";
+import { ErrorMessage } from "../../ErrorMessage";
+import Spinner from "../../../views/elements/Spinner";
+import Field from "../../../views/elements/Field";
+
+interface EnterEmailProps {
+ email: string;
+ errorMessage: string | null;
+ loading: boolean;
+ onInputChanged: (stateKey: string, ev: React.FormEvent) => void;
+ onSubmitForm: (ev: React.FormEvent) => void;
+}
+
+/**
+ * This component renders the email input view of the forgot password flow.
+ */
+export const EnterEmail: React.FC = ({
+ email,
+ errorMessage,
+ loading,
+ onInputChanged,
+ onSubmitForm,
+}) => {
+ const submitButtonChild = loading
+ ?
+ : _t("Send email");
+
+ const emailFieldRef = useRef(null);
+
+ const onSubmit = async (event: React.FormEvent) => {
+ if (await emailFieldRef.current?.validate({ allowEmpty: false })) {
+ onSubmitForm(event);
+ return;
+ }
+
+ emailFieldRef.current?.focus();
+ emailFieldRef.current?.validate({ allowEmpty: false, focused: true });
+ };
+
+ return
+
+
{ _t("Enter your email to reset password") }
+
+ {
+ _t(
+ "%(homeserver)s will send you a verification link to let you reset your password.",
+ { homeserver: "matrix.org" },
+ { b: t => { t } },
+ )
+ }
+
+
+
;
+};
diff --git a/src/components/structures/auth/forgot-password/VerifyEmailModal.tsx b/src/components/structures/auth/forgot-password/VerifyEmailModal.tsx
new file mode 100644
index 000000000000..0f3a9fca8b8e
--- /dev/null
+++ b/src/components/structures/auth/forgot-password/VerifyEmailModal.tsx
@@ -0,0 +1,75 @@
+/*
+Copyright 2022 The Matrix.org Foundation C.I.C.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import React, { useRef, useState } from "react";
+
+import { _t } from "../../../../languageHandler";
+import AccessibleButton from "../../../views/elements/AccessibleButton";
+import { Icon as RetryIcon } from "../../../../../res/img/element-icons/retry.svg";
+import { Icon as EMailPromptIcon } from "../../../../../res/img/element-icons/email-prompt.svg";
+import Tooltip, { Alignment } from "../../../views/elements/Tooltip";
+
+interface Props {
+ email: string;
+ onResendClick: () => Promise;
+}
+
+export const VerifyEmailModal: React.FC = ({
+ email,
+ onResendClick,
+}) => {
+ const resentTooltipVisibleTimerId = useRef(null);
+ const [resentTooltipVisible, setResentTooltipVisible] = useState(false);
+
+ const onResendClickFn = async (): Promise => {
+ await onResendClick();
+ setResentTooltipVisible(true);
+ resentTooltipVisibleTimerId.current = setTimeout(() => setResentTooltipVisible(false), 2500);
+ };
+
+ return
+
+
{ _t("Verify your email to continue") }
+
+ { _t(
+ `We need to know it’s you before resetting your password.
+ Click the link in the email we just sent to %(email)s`,
+ {
+ email,
+ },
+ {
+ b: sub => { sub },
+ },
+ ) }
+
+
+
{ _t("Did not receive it?") }
+
+
+ { _t("Resend") }
+
+
+
+
;
+};
diff --git a/src/components/views/dialogs/QuestionDialog.tsx b/src/components/views/dialogs/QuestionDialog.tsx
index b1e913dc8ea3..bc91d0a0f9c2 100644
--- a/src/components/views/dialogs/QuestionDialog.tsx
+++ b/src/components/views/dialogs/QuestionDialog.tsx
@@ -39,7 +39,7 @@ export interface IQuestionDialogProps extends IDialogProps {
cancelButton?: React.ReactNode;
}
-export default class QuestionDialog extends React.Component {
+const QuestionDialog: React.ComponentClass = class extends React.Component {
public static defaultProps: Partial = {
title: "",
description: "",
@@ -90,4 +90,6 @@ export default class QuestionDialog extends React.Component
);
}
-}
+};
+
+export default QuestionDialog;
diff --git a/src/components/views/elements/Field.tsx b/src/components/views/elements/Field.tsx
index 59f16caacd19..3a0c3ef155f7 100644
--- a/src/components/views/elements/Field.tsx
+++ b/src/components/views/elements/Field.tsx
@@ -290,7 +290,7 @@ export default class Field extends React.PureComponent {
let fieldTooltip;
if (tooltipContent || this.state.feedback) {
fieldTooltip = %(email)s": "We need to know it’s you before resetting your password.\n Click the link in the email we just sent to %(email)s",
+ "Did not receive it?": "Did not receive it?",
"Resetting your password on this homeserver will cause all of your devices to be signed out. This will delete the message encryption keys stored on them, making encrypted chat history unreadable.": "Resetting your password on this homeserver will cause all of your devices to be signed out. This will delete the message encryption keys stored on them, making encrypted chat history unreadable.",
"Signing out your devices will delete the message encryption keys stored on them, making encrypted chat history unreadable.": "Signing out your devices will delete the message encryption keys stored on them, making encrypted chat history unreadable.",
"If you want to retain access to your chat history in encrypted rooms, set up Key Backup or export your message keys from one of your other devices before proceeding.": "If you want to retain access to your chat history in encrypted rooms, set up Key Backup or export your message keys from one of your other devices before proceeding.",
- "The email address linked to your account must be entered.": "The email address linked to your account must be entered.",
- "The email address doesn't appear to be valid.": "The email address doesn't appear to be valid.",
+ "Reset your password": "Reset your password",
+ "Confirm new password": "Confirm new password",
"A new password must be entered.": "A new password must be entered.",
"New passwords must match each other.": "New passwords must match each other.",
- "Sign out all devices": "Sign out all devices",
- "A verification email will be sent to your inbox to confirm setting your new password.": "A verification email will be sent to your inbox to confirm setting your new password.",
- "Send Reset Email": "Send Reset Email",
- "Sign in instead": "Sign in instead",
- "An email has been sent to %(emailAddress)s. Once you've followed the link it contains, click below.": "An email has been sent to %(emailAddress)s. Once you've followed the link it contains, click below.",
- "I have verified my email address": "I have verified my email address",
+ "Sign out of all devices": "Sign out of all devices",
+ "Reset password": "Reset password",
"Your password has been reset.": "Your password has been reset.",
"You have been logged out of all devices and will no longer receive push notifications. To re-enable notifications, sign in again on each device.": "You have been logged out of all devices and will no longer receive push notifications. To re-enable notifications, sign in again on each device.",
"Return to login screen": "Return to login screen",
- "Set a new password": "Set a new password",
"Invalid homeserver discovery response": "Invalid homeserver discovery response",
"Failed to get autodiscovery configuration from server": "Failed to get autodiscovery configuration from server",
"Invalid base_url for m.homeserver": "Invalid base_url for m.homeserver",
@@ -3498,6 +3495,13 @@
"You're signed out": "You're signed out",
"Clear personal data": "Clear personal data",
"Warning: Your personal data (including encryption keys) is still stored in this session. Clear it if you're finished using this session, or want to sign in to another account.": "Warning: Your personal data (including encryption keys) is still stored in this session. Clear it if you're finished using this session, or want to sign in to another account.",
+ "Follow the instructions sent to %(email)s": "Follow the instructions sent to %(email)s",
+ "Verification link email resent!": "Verification link email resent!",
+ "Send email": "Send email",
+ "Enter your email to reset password": "Enter your email to reset password",
+ "%(homeserver)s will send you a verification link to let you reset your password.": "%(homeserver)s will send you a verification link to let you reset your password.",
+ "The email address linked to your account must be entered.": "The email address linked to your account must be entered.",
+ "The email address doesn't appear to be valid.": "The email address doesn't appear to be valid.",
"Commands": "Commands",
"Command Autocomplete": "Command Autocomplete",
"Emoji Autocomplete": "Emoji Autocomplete",
diff --git a/tsconfig.json b/tsconfig.json
index 69749ab96bcf..12590d680df7 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -13,6 +13,7 @@
"outDir": "./lib",
"declaration": true,
"jsx": "react",
+ "strict": true,
"lib": [
"es2020",
"dom",