Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fc9987a

Browse files
authored
Merge pull request #646 from matrix-org/matthew/password-reset-warning
Warn users of E2E key loss when changing/resetting passwords or logging out
2 parents 770820e + 6a40abb commit fc9987a

File tree

5 files changed

+75
-87
lines changed

5 files changed

+75
-87
lines changed

src/component-index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ import views$dialogs$ErrorDialog from './components/views/dialogs/ErrorDialog';
7979
views$dialogs$ErrorDialog && (module.exports.components['views.dialogs.ErrorDialog'] = views$dialogs$ErrorDialog);
8080
import views$dialogs$InteractiveAuthDialog from './components/views/dialogs/InteractiveAuthDialog';
8181
views$dialogs$InteractiveAuthDialog && (module.exports.components['views.dialogs.InteractiveAuthDialog'] = views$dialogs$InteractiveAuthDialog);
82-
import views$dialogs$LogoutPrompt from './components/views/dialogs/LogoutPrompt';
83-
views$dialogs$LogoutPrompt && (module.exports.components['views.dialogs.LogoutPrompt'] = views$dialogs$LogoutPrompt);
8482
import views$dialogs$NeedToRegisterDialog from './components/views/dialogs/NeedToRegisterDialog';
8583
views$dialogs$NeedToRegisterDialog && (module.exports.components['views.dialogs.NeedToRegisterDialog'] = views$dialogs$NeedToRegisterDialog);
8684
import views$dialogs$QuestionDialog from './components/views/dialogs/QuestionDialog';

src/components/structures/UserSettings.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,26 @@ module.exports = React.createClass({
229229
},
230230

231231
onLogoutClicked: function(ev) {
232-
var LogoutPrompt = sdk.getComponent('dialogs.LogoutPrompt');
233-
this.logoutModal = Modal.createDialog(LogoutPrompt);
232+
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
233+
Modal.createDialog(QuestionDialog, {
234+
title: "Sign out?",
235+
description:
236+
<div>
237+
For security, logging out will delete any end-to-end encryption keys from this browser,
238+
making previous encrypted chat history unreadable if you log back in.
239+
In future this <a href="https://github.com/vector-im/riot-web/issues/2108">will be improved</a>,
240+
but for now be warned.
241+
</div>,
242+
button: "Sign out",
243+
onFinished: (confirmed) => {
244+
if (confirmed) {
245+
dis.dispatch({action: 'logout'});
246+
if (this.props.onFinished) {
247+
this.props.onFinished();
248+
}
249+
}
250+
},
251+
});
234252
},
235253

236254
onPasswordChangeError: function(err) {

src/components/structures/login/ForgotPassword.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,26 @@ module.exports = React.createClass({
8787
this.showErrorDialog("New passwords must match each other.");
8888
}
8989
else {
90-
this.submitPasswordReset(
91-
this.state.enteredHomeserverUrl, this.state.enteredIdentityServerUrl,
92-
this.state.email, this.state.password
93-
);
90+
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
91+
Modal.createDialog(QuestionDialog, {
92+
title: "Warning",
93+
description:
94+
<div>
95+
Resetting password will currently reset any end-to-end encryption keys on all devices,
96+
making encrypted chat history unreadable.
97+
In future this <a href="https://github.com/vector-im/riot-web/issues/2671">may be improved</a>,
98+
but for now be warned.
99+
</div>,
100+
button: "Continue",
101+
onFinished: (confirmed) => {
102+
if (confirmed) {
103+
this.submitPasswordReset(
104+
this.state.enteredHomeserverUrl, this.state.enteredIdentityServerUrl,
105+
this.state.email, this.state.password
106+
);
107+
}
108+
},
109+
});
94110
}
95111
},
96112

src/components/views/dialogs/LogoutPrompt.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

src/components/views/settings/ChangePassword.js

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818

1919
var React = require('react');
2020
var MatrixClientPeg = require("../../../MatrixClientPeg");
21+
var Modal = require("../../../Modal");
2122
var sdk = require("../../../index");
2223
import AccessibleButton from '../elements/AccessibleButton';
2324

@@ -66,26 +67,42 @@ module.exports = React.createClass({
6667
changePassword: function(old_password, new_password) {
6768
var cli = MatrixClientPeg.get();
6869

69-
var authDict = {
70-
type: 'm.login.password',
71-
user: cli.credentials.userId,
72-
password: old_password
73-
};
70+
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
71+
Modal.createDialog(QuestionDialog, {
72+
title: "Warning",
73+
description:
74+
<div>
75+
Changing password will currently reset any end-to-end encryption keys on all devices,
76+
making encrypted chat history unreadable.
77+
This will be <a href="https://github.com/vector-im/riot-web/issues/2671">improved shortly</a>,
78+
but for now be warned.
79+
</div>,
80+
button: "Continue",
81+
onFinished: (confirmed) => {
82+
if (confirmed) {
83+
var authDict = {
84+
type: 'm.login.password',
85+
user: cli.credentials.userId,
86+
password: old_password
87+
};
7488

75-
this.setState({
76-
phase: this.Phases.Uploading
89+
this.setState({
90+
phase: this.Phases.Uploading
91+
});
92+
93+
var self = this;
94+
cli.setPassword(authDict, new_password).then(function() {
95+
self.props.onFinished();
96+
}, function(err) {
97+
self.props.onError(err);
98+
}).finally(function() {
99+
self.setState({
100+
phase: self.Phases.Edit
101+
});
102+
}).done();
103+
}
104+
},
77105
});
78-
79-
var self = this;
80-
cli.setPassword(authDict, new_password).then(function() {
81-
self.props.onFinished();
82-
}, function(err) {
83-
self.props.onError(err);
84-
}).finally(function() {
85-
self.setState({
86-
phase: self.Phases.Edit
87-
});
88-
}).done();
89106
},
90107

91108
onClickChange: function() {

0 commit comments

Comments
 (0)