diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 7c507c2c50..23bf5f60a5 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -42,11 +42,11 @@ function logout() { // logout doesn't work for guest sessions // Also we sometimes want to re-log in a guest session // if we abort the login - _onLoggedOut(); + onLoggedOut(); return; } - return MatrixClientPeg.get().logout().then(_onLoggedOut, + return 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 @@ -56,7 +56,7 @@ function logout() { // 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(); + onLoggedOut(); } ); } @@ -79,7 +79,11 @@ function startMatrixClient() { MatrixClientPeg.start(); } -function _onLoggedOut() { +/* + * Stops a running client and all related services, used after + * a session has been logged out / ended. + */ +function onLoggedOut() { if (window.localStorage) { const hsUrl = window.localStorage.getItem("mx_hs_url"); const isUrl = window.localStorage.getItem("mx_is_url"); @@ -95,7 +99,9 @@ function _onLoggedOut() { dis.dispatch({action: 'on_logged_out'}); } -// stop all the background processes related to the current client +/** + * Stop all the background processes related to the current client + */ function _stopMatrixClient() { Notifier.stop(); UserActivity.stop(); @@ -106,5 +112,5 @@ function _stopMatrixClient() { } module.exports = { - setLoggedIn, logout, startMatrixClient + setLoggedIn, logout, startMatrixClient, onLoggedOut }; diff --git a/src/component-index.js b/src/component-index.js index ca8887858c..97f8882b82 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -45,6 +45,7 @@ module.exports.components['views.avatars.RoomAvatar'] = require('./components/vi module.exports.components['views.create_room.CreateRoomButton'] = require('./components/views/create_room/CreateRoomButton'); module.exports.components['views.create_room.Presets'] = require('./components/views/create_room/Presets'); module.exports.components['views.create_room.RoomAlias'] = require('./components/views/create_room/RoomAlias'); +module.exports.components['views.dialogs.DeactivateAccountDialog'] = require('./components/views/dialogs/DeactivateAccountDialog'); module.exports.components['views.dialogs.ErrorDialog'] = require('./components/views/dialogs/ErrorDialog'); module.exports.components['views.dialogs.LogoutPrompt'] = require('./components/views/dialogs/LogoutPrompt'); module.exports.components['views.dialogs.NeedToRegisterDialog'] = require('./components/views/dialogs/NeedToRegisterDialog'); diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index 6555668ff4..89146229fa 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -262,6 +262,11 @@ module.exports = React.createClass({ }); }, + _onDeactivateAccountClicked: function() { + const DeactivateAccountDialog = sdk.getComponent("dialogs.DeactivateAccountDialog"); + Modal.createDialog(DeactivateAccountDialog, {}); + }, + _renderUserInterfaceSettings: function() { var client = MatrixClientPeg.get(); @@ -379,6 +384,20 @@ module.exports = React.createClass({ ) }, + _renderDeactivateAccount: function() { + // We can't deactivate a guest account. + if (MatrixClientPeg.get().isGuest()) return null; + + return
This will make your account permanently unusable. You will not be able to re-register the same user ID.
+ +This action is irreversible.
+ +To continue, please enter your password.
+ +Password:
+ {this._passwordField = e;}} + className={passwordBoxClass} + /> + {error} +