Files
threshold-ui/ui/admin/app/routes/scopes/index.js
T
Zhihe Li bcf004b8a4 Reformat codebase with trailing commas in functions (#2006)
* style: 💄 Update trailing commas in API

* style: 💄 Update trailing commas in core

* style: 💄 Update trailing commas in rose

* style: 💄 Update trailing commas in admin

* style: 💄 Update trailing commas in desktop
2023-11-22 14:07:41 -05:00

36 lines
876 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[0]
*/
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');
}
}
}