Files
threshold-ui/ui/desktop/app/routes/scopes/scope/projects/sessions/session.js
T
Cameron Perera f879bbb1ec Session permissions issue (#1975)
* refactor: 💡 session isCancelable to isAvailable

* refactor: 💡 check for target info for showing target details

* refactor: 💡 add fallback for session data from connect command

* refactor: 💡 remove extra divs

* refactor: 💡 remove await from peekRecord of a session

* test: 💍 add test for no read permission for sessions

* test: 💍 reset global qunit after test is done
2023-11-01 11:22:18 -05:00

41 lines
910 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';
export default class ScopesScopeProjectsSessionsSessionRoute extends Route {
// =services
@service store;
// =methods
/**
* Load a session
* @param {object} params
* @param {string} params.session_id
* @return {SessionModel}
*/
async model({ session_id }) {
const session = await this.store.findRecord('session', session_id);
/**
* If the session has a host_id and the user has grants,
* we retrieve the host and aggregate it to the session model.
*/
if (session.host_id) {
try {
const host = await this.store.findRecord('host', session.host_id);
session.addHost(host);
} catch (error) {
// no operation
}
}
return session;
}
}