Step 8.5: Move logout call during deactivation

This commit is contained in:
Travis Ralston 2022-03-24 16:11:01 -06:00
parent bcf413734b
commit c8582c7199
3 changed files with 20 additions and 2 deletions

View file

@ -60,10 +60,18 @@ import StorageEvictedDialog from "./components/views/dialogs/StorageEvictedDialo
import { setSentryUser } from "./sentry"; import { setSentryUser } from "./sentry";
import SdkConfig from "./SdkConfig"; import SdkConfig from "./SdkConfig";
import { DialogOpener } from "./utils/DialogOpener"; import { DialogOpener } from "./utils/DialogOpener";
import { Action } from "./dispatcher/actions";
const HOMESERVER_URL_KEY = "mx_hs_url"; const HOMESERVER_URL_KEY = "mx_hs_url";
const ID_SERVER_URL_KEY = "mx_is_url"; const ID_SERVER_URL_KEY = "mx_is_url";
dis.register((payload) => {
if (payload.action === Action.TriggerLogout) {
// noinspection JSIgnoredPromiseFromCall - we don't care if it fails
onLoggedOut();
}
});
interface ILoadSessionOpts { interface ILoadSessionOpts {
enableGuest?: boolean; enableGuest?: boolean;
guestHsUrl?: string; guestHsUrl?: string;

View file

@ -21,12 +21,13 @@ import { logger } from "matrix-js-sdk/src/logger";
import Analytics from '../../../Analytics'; import Analytics from '../../../Analytics';
import { MatrixClientPeg } from '../../../MatrixClientPeg'; import { MatrixClientPeg } from '../../../MatrixClientPeg';
import * as Lifecycle from '../../../Lifecycle';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import InteractiveAuth, { ERROR_USER_CANCELLED } from "../../structures/InteractiveAuth"; import InteractiveAuth, { ERROR_USER_CANCELLED } from "../../structures/InteractiveAuth";
import { DEFAULT_PHASE, PasswordAuthEntry, SSOAuthEntry } from "../auth/InteractiveAuthEntryComponents"; import { DEFAULT_PHASE, PasswordAuthEntry, SSOAuthEntry } from "../auth/InteractiveAuthEntryComponents";
import StyledCheckbox from "../elements/StyledCheckbox"; import StyledCheckbox from "../elements/StyledCheckbox";
import BaseDialog from "./BaseDialog"; import BaseDialog from "./BaseDialog";
import defaultDispatcher from "../../../dispatcher/dispatcher";
import { Action } from "../../../dispatcher/actions";
interface IProps { interface IProps {
onFinished: (success: boolean) => void; onFinished: (success: boolean) => void;
@ -122,7 +123,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
MatrixClientPeg.get().deactivateAccount(auth, this.state.shouldErase).then(r => { MatrixClientPeg.get().deactivateAccount(auth, this.state.shouldErase).then(r => {
// Deactivation worked - logout & close this dialog // Deactivation worked - logout & close this dialog
Analytics.trackEvent('Account', 'Deactivate Account'); Analytics.trackEvent('Account', 'Deactivate Account');
Lifecycle.onLoggedOut(); defaultDispatcher.fire(Action.TriggerLogout);
this.props.onFinished(true); this.props.onFinished(true);
}).catch(e => { }).catch(e => {
logger.error(e); logger.error(e);

View file

@ -283,4 +283,13 @@ export enum Action {
* Payload: OpenTabbedIntegrationManagerDialogPayload * Payload: OpenTabbedIntegrationManagerDialogPayload
*/ */
OpenTabbedIntegrationManagerDialog = "open_tabbed_imanager_dialog", OpenTabbedIntegrationManagerDialog = "open_tabbed_imanager_dialog",
/**
* Fired when something within the application has determined that a logout,
* or logout-like behaviour, needs to happen. Specifically meant to target
* storage deletion rather than calling the logout API.
*
* No payload.
*/
TriggerLogout = "trigger_logout",
} }