Skip to content

Commit d3652ad

Browse files
authored
services/session: Clear in-memory data when logging out (#5180)
1 parent e72a5fe commit d3652ad

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

app/services/session.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@ export default class SessionService extends Service {
124124
logoutTask = task(async () => {
125125
await ajax(`/api/private/session`, { method: 'DELETE' });
126126

127-
this.savedTransition = null;
128127
this.isLoggedIn = false;
129128

130-
await this.loadUserTask.cancelAll({ resetState: true });
131-
this.sentry.setUser(null);
132-
133-
this.router.transitionTo('index');
129+
// We perform a proper page navigation here instead of an in-app transition to ensure
130+
// that the Ember Data store and any other in-memory data is cleared on logout.
131+
window.location.assign('/');
134132
});
135133

136134
loadUserTask = dropTask(async () => {

tests/acceptance/logout-test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { click, currentURL, visit } from '@ember/test-helpers';
22
import { module, test } from 'qunit';
33

4+
import window from 'ember-window-mock';
5+
import { setupWindowMock } from 'ember-window-mock/test-support';
6+
47
import { setupApplicationTest } from 'cargo/tests/helpers';
58

69
module('Acceptance | Logout', function (hooks) {
710
setupApplicationTest(hooks);
11+
setupWindowMock(hooks);
812

913
test('successful logout', async function (assert) {
1014
let user = this.server.create('user', { name: 'John Doe' });
@@ -17,7 +21,6 @@ module('Acceptance | Logout', function (hooks) {
1721
await click('[data-test-user-menu] [data-test-toggle]');
1822
await click('[data-test-user-menu] [data-test-logout-button]');
1923

20-
assert.equal(currentURL(), '/');
21-
assert.dom('[data-test-user-menu] [data-test-toggle]').doesNotExist();
24+
assert.equal(window.location.pathname, '/');
2225
});
2326
});

0 commit comments

Comments
 (0)