From 066f72fcdb74cd5df17af6864c152ac5e8bad09e Mon Sep 17 00:00:00 2001 From: Panagiotis <27917356+panoschal@users.noreply.github.com> Date: Thu, 11 Mar 2021 00:14:55 +0200 Subject: [PATCH 01/25] feat: require strong password in forgot password form --- .../structures/auth/ForgotPassword.js | 22 ++++++++++++++++--- src/i18n/strings/en_EN.json | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/structures/auth/ForgotPassword.js b/src/components/structures/auth/ForgotPassword.js index 5a39fe9fd9..45270323b0 100644 --- a/src/components/structures/auth/ForgotPassword.js +++ b/src/components/structures/auth/ForgotPassword.js @@ -18,7 +18,7 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; -import { _t } from '../../../languageHandler'; +import { _t, _td } from '../../../languageHandler'; import * as sdk from '../../../index'; import Modal from "../../../Modal"; import PasswordReset from "../../../PasswordReset"; @@ -27,6 +27,9 @@ import classNames from 'classnames'; import AuthPage from "../../views/auth/AuthPage"; import CountlyAnalytics from "../../../CountlyAnalytics"; import ServerPicker from "../../views/elements/ServerPicker"; +import PassphraseField from '../../views/auth/PassphraseField'; + +const PASSWORD_MIN_SCORE = 3; // safely unguessable: moderate protection from offline slow-hash scenario. // Phases // Show the forgot password inputs @@ -135,10 +138,14 @@ export default class ForgotPassword extends React.Component { // refresh the server errors, just in case the server came back online await this._checkServerLiveliness(this.props.serverConfig); + await this['password_field'].validate({ allowEmpty: false }); + if (!this.state.email) { this.showErrorDialog(_t('The email address linked to your account must be entered.')); } else if (!this.state.password || !this.state.password2) { this.showErrorDialog(_t('A new password must be entered.')); + } else if (!this.state.passwordFieldValid) { + this.showErrorDialog(_t('Please choose a strong password')); } else if (this.state.password !== this.state.password2) { this.showErrorDialog(_t('New passwords must match each other.')); } else { @@ -184,6 +191,12 @@ export default class ForgotPassword extends React.Component { }); } + onPasswordValidate(result) { + this.setState({ + passwordFieldValid: result.valid, + }); + } + renderForgot() { const Field = sdk.getComponent('elements.Field'); @@ -228,12 +241,15 @@ export default class ForgotPassword extends React.Component { />
+ {_t( + "Your event store appears corrupted. " + + "This action will restart this application.", + )} +
+
{EventIndexPeg.error.message}
+
+
{_t(
From b38f5c945920d98aa1964a6685e14ff647148468 Mon Sep 17 00:00:00 2001
From: Germain Souquet
{_t(
- "Your event store appears corrupted. " +
- "This action will restart this application.",
+ "Your event store appears to be corrupted. " +
+ "Your messages will be re-indexed as soon as the store is initialised.",
)}
- {_t("Message search initilisation failed")}
+ {this.state.enabling
+ ?
- {_t(
- "Your event store appears to be corrupted. " +
- "Your messages will be re-indexed as soon as the store is initialised.",
+ {_t("You most likely do not want to reset your event index store")}
+
+ {_t("If you do, please note that none of your messages will be deleted, " +
+ "but the search experience might be degraded for a few moments" +
+ "whilst the index is recreated",
)}