Files
threshold-ui/ui/admin/app/routes/scopes/scope/authenticate.js
T

37 lines
985 B
JavaScript
Raw Normal View History

import Route from '@ember/routing/route';
2020-07-24 18:08:37 -04:00
import { inject as service } from '@ember/service';
import { hash } from 'rsvp';
export default class ScopesScopeAuthenticateRoute extends Route {
2020-07-24 18:08:37 -04:00
// =services
@service session;
@service router;
2020-07-24 18:08:37 -04:00
// =methods
2020-10-01 17:42:55 -04:00
beforeModel() {
if (this.session.isAuthenticated)
this.router.transitionTo('scopes.scope.index');
2020-10-01 17:42:55 -04:00
}
/**
* Returns all auth methods for the current scope, along with the current
* scope and all scopes (for org navigation).
* @return {Promise} `{scope, scopes, authMethods}`
*/
model() {
2020-09-09 12:24:01 -04:00
const { id: scope_id } = this.modelFor('scopes.scope');
return hash({
scope: this.modelFor('scopes.scope'),
2020-11-16 15:08:59 -05:00
scopes: this.modelFor('scopes').filter((scope) => scope.isOrg),
2020-09-09 12:24:01 -04:00
authMethods: this.store.query('auth-method', { scope_id }),
// for integration testing:
// authMethods: A([{
// id: 'am_1234567890',
// type: 'password'
// }])
});
}
}