From 6cac8011971bf870976a0b8edfaf5d1637e08b6e Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 7 Feb 2021 10:31:51 +0100 Subject: [PATCH 1/3] simple-auth: Fix `AuthenticatedRouteMixin` deprecation warnings --- ember/app/routes/flight-upload.js | 9 ++++++--- ember/app/routes/notifications.js | 9 ++++++--- ember/app/routes/settings.js | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ember/app/routes/flight-upload.js b/ember/app/routes/flight-upload.js index 48997d4fb8..cd70ce151f 100644 --- a/ember/app/routes/flight-upload.js +++ b/ember/app/routes/flight-upload.js @@ -1,11 +1,14 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; - -export default class FlightUploadRoute extends Route.extend(AuthenticatedRouteMixin) { +export default class FlightUploadRoute extends Route { @service ajax; @service account; + @service session; + + beforeModel(transition) { + this.session.requireAuthentication(transition, 'login'); + } async model() { let ajax = this.ajax; diff --git a/ember/app/routes/notifications.js b/ember/app/routes/notifications.js index 18f146f01e..8e4847815a 100644 --- a/ember/app/routes/notifications.js +++ b/ember/app/routes/notifications.js @@ -1,12 +1,11 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; - const PER_PAGE = 20; -export default Route.extend(AuthenticatedRouteMixin, { +export default Route.extend({ ajax: service(), + session: service(), queryParams: { page: { refreshModel: true }, @@ -14,6 +13,10 @@ export default Route.extend(AuthenticatedRouteMixin, { type: { refreshModel: true }, }, + beforeModel(transition) { + this.session.requireAuthentication(transition, 'login'); + }, + model(params) { let data = { page: params.page, diff --git a/ember/app/routes/settings.js b/ember/app/routes/settings.js index 0bed239c23..4a471c0f10 100644 --- a/ember/app/routes/settings.js +++ b/ember/app/routes/settings.js @@ -1,10 +1,13 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; -import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; - -export default class SettingsRoute extends Route.extend(AuthenticatedRouteMixin) { +export default class SettingsRoute extends Route { @service ajax; + @service session; + + beforeModel(transition) { + this.session.requireAuthentication(transition, 'login'); + } model() { return this.ajax.request('/api/settings/'); From f70c66757985aefc9a14e59ef15cc4c01a4779dc Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 7 Feb 2021 10:33:08 +0100 Subject: [PATCH 2/3] simple-auth: Fix `UnauthenticatedRouteMixin` deprecation warnings --- ember/app/routes/login.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ember/app/routes/login.js b/ember/app/routes/login.js index 2edcc47b0f..263d4e46e4 100644 --- a/ember/app/routes/login.js +++ b/ember/app/routes/login.js @@ -1,8 +1,13 @@ import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; -import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin'; +export default class LoginRoute extends Route { + @service session; + + beforeModel() { + this.session.prohibitAuthentication('index'); + } -export default class LoginRoute extends Route.extend(UnauthenticatedRouteMixin) { setupController() { super.setupController(...arguments); this.controllerFor('application').set('inLoginRoute', true); From 9931bf96ce0c5136fa8add5f6371fb46581cab97 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 7 Feb 2021 10:39:18 +0100 Subject: [PATCH 3/3] simple-auth: Remove obsolete `ApplicationRouteMixin` mixin usage --- ember/app/routes/application.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/ember/app/routes/application.js b/ember/app/routes/application.js index c5fdc8258f..e093cfbb20 100644 --- a/ember/app/routes/application.js +++ b/ember/app/routes/application.js @@ -7,13 +7,12 @@ import Ember from 'ember'; import RSVP from 'rsvp'; import * as Sentry from '@sentry/browser'; -import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin'; import _availableLocales from '../utils/locales'; const FALLBACK_LOCALE = 'en'; -export default class ApplicationRoute extends Route.extend(ApplicationRouteMixin) { +export default class ApplicationRoute extends Route { @service account; @service ajax; @service cookies; @@ -80,18 +79,6 @@ export default class ApplicationRoute extends Route.extend(ApplicationRouteMixin } } - sessionAuthenticated() { - const attemptedTransition = this.get('session.attemptedTransition'); - const inLoginRoute = this.controllerFor('application').get('inLoginRoute'); - - if (attemptedTransition) { - attemptedTransition.retry(); - this.set('session.attemptedTransition', null); - } else if (inLoginRoute) { - this.transitionTo('index'); - } - } - @action loading(transition) { this.progress.handle(transition);