From 10fe08c28dea105a5d58a31d9ddcb1bbf6e8e983 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Fri, 26 Feb 2021 12:04:12 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20rip=20out=20deprecated?= =?UTF-8?q?=20route=20mixin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/routes/application.js | 36 +---------------- .../tests/acceptance/authentication-test.js | 39 ++++++++++--------- ui/desktop/app/routes/application.js | 36 +---------------- 3 files changed, 23 insertions(+), 88 deletions(-) diff --git a/ui/admin/app/routes/application.js b/ui/admin/app/routes/application.js index a4d4cc6ef..be7f8b034 100644 --- a/ui/admin/app/routes/application.js +++ b/ui/admin/app/routes/application.js @@ -1,20 +1,14 @@ import Route from '@ember/routing/route'; -/* eslint-disable-next-line ember/no-mixins */ -import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; -import Ember from 'ember'; import { getOwner } from '@ember/application'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; -import { later } from '@ember/runloop'; import loading from 'ember-loading/decorator'; import { A } from '@ember/array'; /** * Entry route for the application. */ -export default class ApplicationRoute extends Route.extend( - ApplicationRouteMixin -) { +export default class ApplicationRoute extends Route { // =services @service session; @@ -31,34 +25,6 @@ export default class ApplicationRoute extends Route.extend( this.toggleTheme(theme); } - /** - * After becoming authenticated, does nothing. This overrides the default - * behavior of the ApplicationRouteMixin, which is to redirect after auth. - * We'll handle this redirect manually in sub routes. - * @override - */ - sessionAuthenticated() { - // no op - } - - /** - * When the session ends, redirect to authenticate and reload the page to - * purge any in-memory state. - */ - async sessionInvalidated() { - // Catch error in this transition, since it will be aborted by the - // scope auth route when it redirects to the first auth method. - await this.transitionTo(this.routeIfUnauthenticated).catch(() => {}); - // The Ember way of accessing globals... - const document = getOwner(this).lookup('service:-document').documentElement; - // defaultView === window, but without using globals directly - const { location } = document.parentNode.defaultView; - // Wait a beat, then reload the page... - // This is mostly to give the deauth request a chance to fire. - /* istanbul ignore if */ - if (!Ember.testing) later(location, location.reload, 150); - } - // =actions /** diff --git a/ui/admin/tests/acceptance/authentication-test.js b/ui/admin/tests/acceptance/authentication-test.js index 872d99d83..502e684af 100644 --- a/ui/admin/tests/acceptance/authentication-test.js +++ b/ui/admin/tests/acceptance/authentication-test.js @@ -5,7 +5,7 @@ import { fillIn, click, find, - findAll, + //findAll, getRootElement, //setupOnerror, } from '@ember/test-helpers'; @@ -282,23 +282,26 @@ module('Acceptance | authentication', function (hooks) { assert.ok(currentSession().isAuthenticated); }); - test('deauthentication redirects to first global authenticate method', async function (assert) { - assert.expect(3); - await visit(authMethodAuthenticateURL); - await fillIn('[name="identification"]', 'test'); - await fillIn('[name="password"]', 'test'); - await click('[type="submit"]'); - assert.ok(currentSession().isAuthenticated); - // Open header utilities dropdown - await click('.rose-header-utilities .rose-dropdown summary'); - // Find and click on last element in dropdown - should be deauthenticate button - const menu = findAll( - '.rose-header-utilities .rose-dropdown .rose-dropdown-content button' - ); - await click(menu[menu.length - 1]); - assert.notOk(currentSession().isAuthenticated); - assert.equal(currentURL(), authMethodGlobalAuthenticateURL); - }); + // This test is disabled because it is no longer relevant. On deauth, + // the page is reloaded. If the user was viewing a route requiring + // authentication, they will be redirected accordingly. + // test('deauthentication redirects to first global authenticate method', async function (assert) { + // assert.expect(3); + // await visit(authMethodAuthenticateURL); + // await fillIn('[name="identification"]', 'test'); + // await fillIn('[name="password"]', 'test'); + // await click('[type="submit"]'); + // assert.ok(currentSession().isAuthenticated); + // // Open header utilities dropdown + // await click('.rose-header-utilities .rose-dropdown summary'); + // // Find and click on last element in dropdown - should be deauthenticate button + // const menu = findAll( + // '.rose-header-utilities .rose-dropdown .rose-dropdown-content button' + // ); + // await click(menu[menu.length - 1]); + // assert.notOk(currentSession().isAuthenticated); + // assert.equal(currentURL(), authMethodGlobalAuthenticateURL); + // }); test('401 responses result in deauthentication', async function (assert) { assert.expect(2); diff --git a/ui/desktop/app/routes/application.js b/ui/desktop/app/routes/application.js index be807e246..27493eb33 100644 --- a/ui/desktop/app/routes/application.js +++ b/ui/desktop/app/routes/application.js @@ -1,18 +1,12 @@ import Route from '@ember/routing/route'; -import Ember from 'ember'; import jQuery from 'jquery'; -/* eslint-disable-next-line ember/no-mixins */ -import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { A } from '@ember/array'; import { getOwner } from '@ember/application'; -import { later } from '@ember/runloop'; import loading from 'ember-loading/decorator'; -export default class ApplicationRoute extends Route.extend( - ApplicationRouteMixin -) { +export default class ApplicationRoute extends Route { // =services @service session; @@ -49,34 +43,6 @@ export default class ApplicationRoute extends Route.extend( }); } - /** - * After becoming authenticated, does nothing. This overrides the default - * behavior of the ApplicationRouteMixin, which is to redirect after auth. - * We'll handle this redirect manually in sub routes. - * @override - */ - sessionAuthenticated() { - // no op - } - - /** - * When the session ends, redirect to authenticate and reload the page to - * purge any in-memory state. - */ - async sessionInvalidated() { - // Catch error in this transition, since it will be aborted by the - // scope auth route when it redirects to the first auth method. - await this.transitionTo(this.routeIfUnauthenticated).catch(() => {}); - // The Ember way of accessing globals... - const document = getOwner(this).lookup('service:-document').documentElement; - // defaultView === window, but without using globals directly - const { location } = document.parentNode.defaultView; - // Wait a beat, then reload the page... - // This is mostly to give the deauth request a chance to fire. - /* istanbul ignore if */ - if (!Ember.testing) later(location, location.reload, 150); - } - // =actions /**