chore: 🤖 add support for changing origin if unauthenticated

This commit is contained in:
Randall Morey committed 2020-11-30 14:16:01 -05:00
1 parent 5e21ac673a
commit 52ae699bc3
1 file changed
+19
+19
View File
@@ -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.