From 52ae699bc3c71972c774712dede1e3c31fce4b8a Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 30 Nov 2020 14:16:01 -0500 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20support=20for=20c?= =?UTF-8?q?hanging=20origin=20if=20unauthenticated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/desktop/app/routes/origin.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui/desktop/app/routes/origin.js b/ui/desktop/app/routes/origin.js index a4cd6a621..ea8104367 100644 --- a/ui/desktop/app/routes/origin.js +++ b/ui/desktop/app/routes/origin.js @@ -5,6 +5,7 @@ import { action } from '@ember/object'; export default class OriginRoute extends Route { // =services + @service session; @service origin; @service intl; @service notify; @@ -20,6 +21,24 @@ export default class OriginRoute extends Route { // =methods + /** + * If arriving here already authenticated, redirect to index for further + * processing. User must be logged out before changing the origin. + */ + beforeModel() { + if (this.session.isAuthenticated) this.replaceWith('index'); + } + + /** + * Adds the existing origin, if any, to the controller scope. + * @param {Controller} controller + */ + setupController(controller) { + super.setupController(...arguments); + const origin = this.origin.rendererOrigin; + controller.setProperties({ origin }); + } + /** * Points the API to the specified origin. When the main process receives * the origin, it is expected that the renderer will be restarted.