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.