From 015d4332351bc543e7f08676425968c48b96c26f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 18 Jun 2018 18:14:48 +0100 Subject: [PATCH] fix a way to get stuck in set password/email flow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserSettings.js | 1 - .../views/dialogs/SetPasswordDialog.js | 7 ++----- src/components/views/globals/PasswordNagBar.js | 16 ++-------------- src/components/views/settings/ChangePassword.js | 7 +++++-- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 2622d7bd89..6397e73434 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -429,7 +429,6 @@ module.exports = React.createClass({ "push notifications on other devices until you log back in to them", ) + ".", }); - dis.dispatch({action: 'password_changed'}); }, _onAddEmailEditFinished: function(value, shouldSubmit) { diff --git a/src/components/views/dialogs/SetPasswordDialog.js b/src/components/views/dialogs/SetPasswordDialog.js index 31c4ad7a3f..42c35ad187 100644 --- a/src/components/views/dialogs/SetPasswordDialog.js +++ b/src/components/views/dialogs/SetPasswordDialog.js @@ -1,5 +1,6 @@ /* Copyright 2017 Vector Creations Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -79,15 +80,11 @@ export default React.createClass({ Modal.createDialog(WarmFuzzy, { didSetEmail: res.didSetEmail, onFinished: () => { - this._onContinueClicked(); + this.props.onFinished(); }, }); }, - _onContinueClicked: function() { - this.props.onFinished(true); - }, - _onPasswordChangeError: function(err) { let errMsg = err.error || ""; if (err.httpStatus === 403) { diff --git a/src/components/views/globals/PasswordNagBar.js b/src/components/views/globals/PasswordNagBar.js index 93f4fe06e5..4233363b95 100644 --- a/src/components/views/globals/PasswordNagBar.js +++ b/src/components/views/globals/PasswordNagBar.js @@ -1,5 +1,6 @@ /* Copyright 2017 Vector Creations Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,28 +15,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -'use strict'; - import React from 'react'; import sdk from '../../../index'; import Modal from '../../../Modal'; -import dis from '../../../dispatcher'; import { _t } from '../../../languageHandler'; export default React.createClass({ onUpdateClicked: function() { const SetPasswordDialog = sdk.getComponent('dialogs.SetPasswordDialog'); - Modal.createTrackedDialog('Set Password Dialog', 'Password Nag Bar', SetPasswordDialog, { - onFinished: (passwordChanged) => { - if (!passwordChanged) { - return; - } - // Notify SessionStore that the user's password was changed - dis.dispatch({ - action: 'password_changed', - }); - }, - }); + Modal.createTrackedDialog('Set Password Dialog', 'Password Nag Bar', SetPasswordDialog); }, render: function() { diff --git a/src/components/views/settings/ChangePassword.js b/src/components/views/settings/ChangePassword.js index 9cac25e6cc..b2ffe531b5 100644 --- a/src/components/views/settings/ChangePassword.js +++ b/src/components/views/settings/ChangePassword.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2018 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,14 +15,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -'use strict'; - const React = require('react'); import PropTypes from 'prop-types'; const MatrixClientPeg = require("../../../MatrixClientPeg"); const Modal = require("../../../Modal"); const sdk = require("../../../index"); +import dis from "../../../dispatcher"; import Promise from 'bluebird'; import AccessibleButton from '../elements/AccessibleButton'; import { _t } from '../../../languageHandler'; @@ -143,6 +143,9 @@ module.exports = React.createClass({ }); cli.setPassword(authDict, newPassword).then(() => { + // Notify SessionStore that the user's password was changed + dis.dispatch({action: 'password_changed'}); + if (this.props.shouldAskForEmail) { return this._optionallySetEmail().then((confirmed) => { this.props.onFinished({