actually, move signout warning to UserSettings.js

also, kill off the inexplicably useless LogoutPrompt in favour of a normal QuestionDialog.
This in turn fixes https://github.com/vector-im/riot-web/issues/2152
This commit is contained in:
Matthew Hodgson 2017-01-24 23:18:25 +01:00
parent 6e55bb4956
commit 6a40abbbf0
3 changed files with 33 additions and 34 deletions

View file

@ -22,7 +22,6 @@ import Notifier from './Notifier';
import UserActivity from './UserActivity'; import UserActivity from './UserActivity';
import Presence from './Presence'; import Presence from './Presence';
import dis from './dispatcher'; import dis from './dispatcher';
import Modal from './Modal';
import DMRoomMap from './utils/DMRoomMap'; import DMRoomMap from './utils/DMRoomMap';
/** /**
@ -290,35 +289,19 @@ export function logout() {
return; return;
} }
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); return MatrixClientPeg.get().logout().then(onLoggedOut,
Modal.createDialog(QuestionDialog, { (err) => {
title: "Warning", // Just throwing an error here is going to be very unhelpful
description: // if you're trying to log out because your server's down and
<div> // you want to log into a different server, so just forget the
For security, logging out will delete any end-to-end encryption keys from this browser, // access token. It's annoying that this will leave the access
making previous encrypted chat history unreadable if you log back in. // token still valid, but we should fix this by having access
In future this <a href="https://github.com/vector-im/riot-web/issues/2108">will be improved</a>, // tokens expire (and if you really think you've been compromised,
but for now be warned. // change your password).
</div>, console.log("Failed to call logout API: token will not be invalidated");
button: "Continue", onLoggedOut();
onFinished: (confirmed) => { }
if (confirmed) { );
MatrixClientPeg.get().logout().then(onLoggedOut,
(err) => {
// Just throwing an error here is going to be very unhelpful
// if you're trying to log out because your server's down and
// you want to log into a different server, so just forget the
// access token. It's annoying that this will leave the access
// token still valid, but we should fix this by having access
// tokens expire (and if you really think you've been compromised,
// change your password).
console.log("Failed to call logout API: token will not be invalidated");
onLoggedOut();
}
);
}
},
});
} }
/** /**

View file

@ -79,8 +79,6 @@ import views$dialogs$ErrorDialog from './components/views/dialogs/ErrorDialog';
views$dialogs$ErrorDialog && (module.exports.components['views.dialogs.ErrorDialog'] = views$dialogs$ErrorDialog); views$dialogs$ErrorDialog && (module.exports.components['views.dialogs.ErrorDialog'] = views$dialogs$ErrorDialog);
import views$dialogs$InteractiveAuthDialog from './components/views/dialogs/InteractiveAuthDialog'; import views$dialogs$InteractiveAuthDialog from './components/views/dialogs/InteractiveAuthDialog';
views$dialogs$InteractiveAuthDialog && (module.exports.components['views.dialogs.InteractiveAuthDialog'] = views$dialogs$InteractiveAuthDialog); views$dialogs$InteractiveAuthDialog && (module.exports.components['views.dialogs.InteractiveAuthDialog'] = views$dialogs$InteractiveAuthDialog);
import views$dialogs$LogoutPrompt from './components/views/dialogs/LogoutPrompt';
views$dialogs$LogoutPrompt && (module.exports.components['views.dialogs.LogoutPrompt'] = views$dialogs$LogoutPrompt);
import views$dialogs$NeedToRegisterDialog from './components/views/dialogs/NeedToRegisterDialog'; import views$dialogs$NeedToRegisterDialog from './components/views/dialogs/NeedToRegisterDialog';
views$dialogs$NeedToRegisterDialog && (module.exports.components['views.dialogs.NeedToRegisterDialog'] = views$dialogs$NeedToRegisterDialog); views$dialogs$NeedToRegisterDialog && (module.exports.components['views.dialogs.NeedToRegisterDialog'] = views$dialogs$NeedToRegisterDialog);
import views$dialogs$QuestionDialog from './components/views/dialogs/QuestionDialog'; import views$dialogs$QuestionDialog from './components/views/dialogs/QuestionDialog';

View file

@ -228,8 +228,26 @@ module.exports = React.createClass({
}, },
onLogoutClicked: function(ev) { onLogoutClicked: function(ev) {
var LogoutPrompt = sdk.getComponent('dialogs.LogoutPrompt'); var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
this.logoutModal = Modal.createDialog(LogoutPrompt); Modal.createDialog(QuestionDialog, {
title: "Sign out?",
description:
<div>
For security, logging out will delete any end-to-end encryption keys from this browser,
making previous encrypted chat history unreadable if you log back in.
In future this <a href="https://github.com/vector-im/riot-web/issues/2108">will be improved</a>,
but for now be warned.
</div>,
button: "Sign out",
onFinished: (confirmed) => {
if (confirmed) {
dis.dispatch({action: 'logout'});
if (this.props.onFinished) {
this.props.onFinished();
}
}
},
});
}, },
onPasswordChangeError: function(err) { onPasswordChangeError: function(err) {