chore: 🤖 clean up auth redirects
This commit is contained in:
12 files changed
+126
-18
No files matched your search
@@ -2,12 +2,14 @@
|
||||
|
||||
{{#if this.scope.org}}
|
||||
{{#unless this.scope.org.isGlobal}}
|
||||
<crumbs.link @route="scopes.scope.scopes" @model="global">
|
||||
{{t "resources.org.title_plural"}}
|
||||
</crumbs.link>
|
||||
<crumbs.link @route="scopes.scope.edit" @model={{this.scope.org.id}}>
|
||||
{{this.scope.org.displayName}}
|
||||
</crumbs.link>
|
||||
{{#if this.session.data.authenticated.isGlobal}}
|
||||
<crumbs.link @route="scopes.scope.scopes" @model="global">
|
||||
{{t "resources.org.title_plural"}}
|
||||
</crumbs.link>
|
||||
<crumbs.link @route="scopes.scope.edit" @model={{this.scope.org.id}}>
|
||||
{{this.scope.org.displayName}}
|
||||
</crumbs.link>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ export default class crumbs extends BreadCrumbsComponent {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
@service scope;
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ export default class ScopesScopeAuthenticateRoute extends Route {
|
||||
const { id: scope_id } = this.modelFor('scopes.scope');
|
||||
return hash({
|
||||
scope: this.modelFor('scopes.scope'),
|
||||
scopes: this.modelFor('scopes'),
|
||||
scopes: this.modelFor('scopes').filter(scope => scope.isOrg),
|
||||
authMethods: this.store.query('auth-method', { scope_id }),
|
||||
|
||||
// for integration testing:
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeEditRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,17 @@ export default class ScopesScopeHostCatalogsRoute extends Route {
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
@service session;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all host catalogs under the current scope.
|
||||
* @return {Promise{[HostCatalogModel]}}
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class ScopesScopeNewRoute extends Route {
|
||||
|
||||
// =services
|
||||
|
||||
@service session;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new unsaved scope belonging to the current scope.
|
||||
* @return {ScopeModel}
|
||||
|
||||
@@ -14,12 +14,10 @@ export default class ScopesScopeScopesRoute extends Route {
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* Redirects to scopes/scope/authenticate if unauthenticated.
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) {
|
||||
this.transitionTo('scopes.scope.authenticate');
|
||||
}
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ export default class ScopesScopeSessionsRoute extends Route {
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
@service session;
|
||||
|
||||
// =attributes
|
||||
|
||||
@@ -37,6 +38,13 @@ export default class ScopesScopeSessionsRoute extends Route {
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all sessions under the current scope and encapsulates them into
|
||||
* an array of objects containing their associated users and targets.
|
||||
|
||||
@@ -10,9 +10,17 @@ export default class ScopesScopeTargetsRoute extends Route {
|
||||
|
||||
@service intl;
|
||||
@service notify;
|
||||
@service session;
|
||||
|
||||
// =methods
|
||||
|
||||
/**
|
||||
* If arriving here unauthenticated, redirect to index for further processing.
|
||||
*/
|
||||
beforeModel() {
|
||||
if (!this.session.isAuthenticated) this.transitionTo('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads all targets under current scope.
|
||||
* @return {Promise{[TargetModel]}}
|
||||
|
||||
@@ -131,15 +131,23 @@
|
||||
</Rose::Nav::Sidebar>
|
||||
{{/unless}}
|
||||
|
||||
{{#unless @model.isGlobal}}
|
||||
{{#if @model.isOrg}}
|
||||
{{#if this.session.data.authenticated.isGlobal}}
|
||||
<Rose::Nav::Sidebar @title={{t "titles.settings"}} as |nav|>
|
||||
<nav.link @route="scopes.scope.edit">
|
||||
{{t "resources.org.messages.settings.title"}}
|
||||
</nav.link>
|
||||
</Rose::Nav::Sidebar>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#if @model.isProject}}
|
||||
<Rose::Nav::Sidebar @title={{t "titles.settings"}} as |nav|>
|
||||
<nav.link @route="scopes.scope.edit">
|
||||
{{t (if @model.isOrg
|
||||
"resources.org.messages.settings.title"
|
||||
"resources.project.messages.settings.title")}}
|
||||
{{t "resources.project.messages.settings.title"}}
|
||||
</nav.link>
|
||||
</Rose::Nav::Sidebar>
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
</sidebarLayout.sidebar>
|
||||
{{/if}}
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
@text={{t "actions.choose-different-org"}}
|
||||
@icon="user-organization"
|
||||
as |dropdown|>
|
||||
<dropdown.link @route="scopes.scope.authenticate" @model="global">
|
||||
{{t "titles.global"}}
|
||||
</dropdown.link>
|
||||
{{#each this.sortedScopes as |scope|}}
|
||||
<dropdown.link @route="scopes.scope.authenticate" @model={{scope.id}}>
|
||||
{{scope.displayName}}
|
||||
|
||||
@@ -39,11 +39,16 @@ module('Acceptance | authentication', function (hooks) {
|
||||
let authMethodGlobalAuthenticateURL;
|
||||
let changePasswordURL;
|
||||
let orgsURL;
|
||||
let orgEditURL;
|
||||
let newProjectURL;
|
||||
let projectsURL;
|
||||
let usersURL;
|
||||
let groupsURL;
|
||||
let rolesURL;
|
||||
let authMethodsURL;
|
||||
let hostCatalogsURL;
|
||||
let sessionsURL;
|
||||
let targetsURL;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
invalidateSession();
|
||||
@@ -73,11 +78,16 @@ module('Acceptance | authentication', function (hooks) {
|
||||
authMethodAuthenticateURL = `/scopes/${orgScopeID}/authenticate/${authMethodID}`;
|
||||
changePasswordURL = `/account/change-password`;
|
||||
orgsURL = `/scopes/global/scopes`;
|
||||
orgEditURL = `/scopes/${orgScopeID}/edit`;
|
||||
newProjectURL = `/scopes/${orgScopeID}/new`;
|
||||
projectsURL = `/scopes/${orgScopeID}/scopes`;
|
||||
usersURL = `/scopes/${orgScopeID}/users`;
|
||||
groupsURL = `/scopes/${orgScopeID}/groups`;
|
||||
rolesURL = `/scopes/${orgScopeID}/roles`;
|
||||
authMethodsURL = `/scopes/${orgScopeID}/auth-methods`;
|
||||
hostCatalogsURL = `/scopes/${orgScopeID}/host-catalogs`;
|
||||
sessionsURL = `/scopes/${orgScopeID}/sessions`;
|
||||
targetsURL = `/scopes/${orgScopeID}/targets`;
|
||||
});
|
||||
|
||||
test('visiting auth methods authenticate route redirects to first auth method', async function (assert) {
|
||||
@@ -129,10 +139,24 @@ module('Acceptance | authentication', function (hooks) {
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting projects while unauthenticated redirects to first org authenticate method', async function (assert) {
|
||||
test('visiting org edit while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(orgEditURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting projects while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(projectsURL);
|
||||
assert.equal(currentURL(), authMethodAuthenticateURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting new project while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(newProjectURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
@@ -157,6 +181,27 @@ module('Acceptance | authentication', function (hooks) {
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting host catalogs while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(hostCatalogsURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting targets while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(targetsURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting sessions while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(sessionsURL);
|
||||
assert.equal(currentURL(), authMethodGlobalAuthenticateURL);
|
||||
assert.notOk(currentSession().isAuthenticated);
|
||||
});
|
||||
|
||||
test('visiting auth methods while unauthenticated redirects to first global authenticate method', async function (assert) {
|
||||
assert.expect(2);
|
||||
await visit(authMethodsURL);
|
||||
|
||||
Reference in new issue
Block a user