diff --git a/ui/core/app/routes/scopes/scope/auth-methods.js b/ui/core/app/routes/scopes/scope/auth-methods.js index ffad801fa..0e35b2c28 100644 --- a/ui/core/app/routes/scopes/scope/auth-methods.js +++ b/ui/core/app/routes/scopes/scope/auth-methods.js @@ -7,9 +7,17 @@ export default class ScopesScopeAuthMethodsRoute 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'); + } + /** * Load all auth-methods under current scope * @return {Promise[AuthMethodModel]} diff --git a/ui/core/app/routes/scopes/scope/groups.js b/ui/core/app/routes/scopes/scope/groups.js index 7eed4406e..c2c75c8fb 100644 --- a/ui/core/app/routes/scopes/scope/groups.js +++ b/ui/core/app/routes/scopes/scope/groups.js @@ -7,9 +7,17 @@ export default class ScopesScopeGroupsRoute 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'); + } + /** * Load all groups under current scope * @return {Promise[GroupModel]} diff --git a/ui/core/app/routes/scopes/scope/orgs.js b/ui/core/app/routes/scopes/scope/orgs.js index f25a91cf9..c2fa56ffc 100644 --- a/ui/core/app/routes/scopes/scope/orgs.js +++ b/ui/core/app/routes/scopes/scope/orgs.js @@ -8,9 +8,17 @@ export default class ScopesScopeOrgsRoute 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 scopes under the global scope. * @return {Promise{[ScopeModel]}} diff --git a/ui/core/app/routes/scopes/scope/roles.js b/ui/core/app/routes/scopes/scope/roles.js index 84cf2ae0f..b0418e399 100644 --- a/ui/core/app/routes/scopes/scope/roles.js +++ b/ui/core/app/routes/scopes/scope/roles.js @@ -7,9 +7,17 @@ export default class ScopesScopeRolesRoute 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'); + } + /** * Load all roles under current scope. * @return {Promise{[RoleModel]}} diff --git a/ui/core/app/routes/scopes/scope/users.js b/ui/core/app/routes/scopes/scope/users.js index f1982b769..20731c90f 100644 --- a/ui/core/app/routes/scopes/scope/users.js +++ b/ui/core/app/routes/scopes/scope/users.js @@ -7,9 +7,17 @@ export default class ScopesScopeUsersRoute 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'); + } + /** * Load all users under current scope. * @return {Promise{[UserModel]}} diff --git a/ui/core/tests/unit/authenticators/password-test.js b/ui/core/tests/unit/authenticators/password-test.js index 21786ec86..8bf59c9ee 100644 --- a/ui/core/tests/unit/authenticators/password-test.js +++ b/ui/core/tests/unit/authenticators/password-test.js @@ -23,12 +23,6 @@ module('Unit | Authenticator | password', function (hooks) { session.invalidate(); }); - test('it does not add an authorization header to application adapter on restore if no token is present', async function (assert) { - assert.expect(1); - authenticator.restore({ token: null }); - assert.notOk(applicationAdapter?.headers?.Authorization); - }); - test('it adds an authorization header to application adapter on restore', async function (assert) { assert.expect(1); authenticator.restore({ token: 'token1234' });