diff --git a/src/components/structures/auth/ForgotPassword.js b/src/components/structures/auth/ForgotPassword.js
index 1fbcd8dfd4..2db13624c3 100644
--- a/src/components/structures/auth/ForgotPassword.js
+++ b/src/components/structures/auth/ForgotPassword.js
@@ -61,7 +61,7 @@ module.exports = React.createClass({
return {
enteredHsUrl: this.props.customHsUrl || this.props.defaultHsUrl,
enteredIsUrl: this.props.customIsUrl || this.props.defaultIsUrl,
- phase: null,
+ phase: PHASE_FORGOT,
password: null,
password2: null,
errorText: null,
@@ -187,103 +187,127 @@ module.exports = React.createClass({
});
},
+ renderServerDetails() {
+ return null;
+ },
+
+ renderForgot() {
+ const ServerConfig = sdk.getComponent("auth.ServerConfig");
+
+ let serverConfigSection;
+ if (!SdkConfig.get()['disable_custom_urls']) {
+ serverConfigSection = (
+
+ );
+ }
+
+ let errorText = null;
+ const err = this.state.errorText || this.props.defaultServerDiscoveryError;
+ if (err) {
+ errorText =
{ err }
;
+ }
+
+ let yourMatrixAccountText = _t('Your account');
+ try {
+ const parsedHsUrl = new URL(this.state.enteredHsUrl);
+ yourMatrixAccountText = _t('Your account on %(serverName)s', {
+ serverName: parsedHsUrl.hostname,
+ });
+ } catch (e) {
+ // ignore
+ }
+
+ return ;
+ },
+
+ renderSendingEmail() {
+ const Spinner = sdk.getComponent("elements.Spinner");
+ return ;
+ },
+
+ renderEmailSent() {
+ return
+ {_t("An email has been sent to %(emailAddress)s. Once you've followed the " +
+ "link it contains, click below.", { emailAddress: this.state.email })}
+
+
+
;
+ },
+
+ renderDone() {
+ return
+
{_t('Your password has been reset')}.
+
{_t('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')}.
+
+
;
+ },
+
render: function() {
const AuthPage = sdk.getComponent("auth.AuthPage");
const AuthHeader = sdk.getComponent("auth.AuthHeader");
const AuthBody = sdk.getComponent("auth.AuthBody");
- const ServerConfig = sdk.getComponent("auth.ServerConfig");
- const Spinner = sdk.getComponent("elements.Spinner");
let resetPasswordJsx;
-
- if (this.state.phase === PHASE_SENDING_EMAIL) {
- resetPasswordJsx = ;
- } else if (this.state.phase === PHASE_EMAIL_SENT) {
- resetPasswordJsx = (
-
- { _t("An email has been sent to %(emailAddress)s. Once you've followed the link it contains, " +
- "click below.", { emailAddress: this.state.email }) }
-
-
-
- );
- } else if (this.state.phase === PHASE_DONE) {
- resetPasswordJsx = (
-
-
{ _t('Your password has been reset') }.
-
{ _t('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') }.
-
-
- );
- } else {
- let serverConfigSection;
- if (!SdkConfig.get()['disable_custom_urls']) {
- serverConfigSection = (
-
- );
- }
-
- let errorText = null;
- const err = this.state.errorText || this.props.defaultServerDiscoveryError;
- if (err) {
- errorText = { err }
;
- }
-
- let yourMatrixAccountText = _t('Your account');
- try {
- const parsedHsUrl = new URL(this.state.enteredHsUrl);
- yourMatrixAccountText = _t('Your account on %(serverName)s', {
- serverName: parsedHsUrl.hostname,
- });
- } catch (e) {
- // ignore
- }
-
- resetPasswordJsx = ;
+ switch (this.state.phase) {
+ case PHASE_SERVER_DETAILS:
+ resetPasswordJsx = this.renderServerDetails();
+ break;
+ case PHASE_FORGOT:
+ resetPasswordJsx = this.renderForgot();
+ break;
+ case PHASE_SENDING_EMAIL:
+ resetPasswordJsx = this.renderSendingEmail();
+ break;
+ case PHASE_EMAIL_SENT:
+ resetPasswordJsx = this.renderEmailSent();
+ break;
+ case PHASE_DONE:
+ resetPasswordJsx = this.renderDone();
+ break;
}
return (