From e16d1b3cfb345fbef76dddb5210870c00fa3f44e Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 20 Jun 2017 11:22:07 +0100 Subject: [PATCH] Implement password nag warning in user settings account section "To return to your account in future you need to set a password" in the account section when a user has not yet set a password (is a PWLU). --- src/components/structures/UserSettings.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index fc13f0bdcf..58ae46e18a 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -21,6 +21,7 @@ const MatrixClientPeg = require("../../MatrixClientPeg"); const PlatformPeg = require("../../PlatformPeg"); const Modal = require('../../Modal'); const dis = require("../../dispatcher"); +import sessionStore from '../../stores/SessionStore'; const q = require('q'); const packageJson = require('../../../package.json'); const UserSettingsStore = require('../../UserSettingsStore'); @@ -243,6 +244,12 @@ module.exports = React.createClass({ this.setState({ language: languageHandler.getCurrentLanguage(), }); + + this._sessionStore = sessionStore; + this._sessionStoreToken = this._sessionStore.addListener( + this._setStateFromSessionStore, + ); + this._setStateFromSessionStore(); }, componentDidMount: function() { @@ -269,6 +276,12 @@ module.exports = React.createClass({ } }, + _setStateFromSessionStore: function() { + this.setState({ + userHasGeneratedPassword: Boolean(this._sessionStore.getCachedPassword()), + }); + }, + _electronSettings: function(ev, settings) { this.setState({ electron_settings: settings }); }, @@ -1201,7 +1214,12 @@ module.exports = React.createClass({

{ _t("Account") }

- + { this.state.userHasGeneratedPassword ? +
+ Warning + { _t("To return to your account in future you need to set a password") } +
: null + } { _t("Sign out") }