Files
threshold-ui/ui/admin/app/routes/scopes/index.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

36 lines
884 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { get } from '@ember/object';
export default class ScopesIndexRoute extends Route {
// =services
@service session;
@service router;
// =methods
/**
* If authenticated, redirects to the scope route of the authenticted scope.
* If unauthenticated, redirects to the first scope that was loaded (if any).
* @param {[ScopeModel]} model
* @param {?ScopeModel} model.firstObject
*/
redirect() {
const authenticatedScopeID = get(
this.session,
'data.authenticated.scope.id'
);
if (authenticatedScopeID) {
this.router.transitionTo('scopes.scope', authenticatedScopeID);
} else {
this.router.transitionTo('scopes.scope', 'global');
}
}
}