diff --git a/app/controllers/catch-all.js b/app/controllers/catch-all.js index 373abce0397..1996f74acbd 100644 --- a/app/controllers/catch-all.js +++ b/app/controllers/catch-all.js @@ -1,7 +1,10 @@ import Controller from '@ember/controller'; import { action } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class CatchAllController extends Controller { + @service session; + @action reload() { this.model.transition.retry(); } diff --git a/app/routes/-authenticated-route.js b/app/routes/-authenticated-route.js index 68b76eedbe7..bcbf49b3324 100644 --- a/app/routes/-authenticated-route.js +++ b/app/routes/-authenticated-route.js @@ -2,7 +2,6 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; export default class AuthenticatedRoute extends Route { - @service notifications; @service router; @service session; @@ -12,9 +11,12 @@ export default class AuthenticatedRoute extends Route { let result = await this.session.loadUserTask.last; if (!result.currentUser) { - this.notifications.error('Please log in to proceed'); this.session.savedTransition = transition; - this.router.transitionTo('index'); + this.router.replaceWith('catch-all', { + transition, + loginNeeded: true, + title: 'This page requires authentication', + }); } } } diff --git a/app/styles/catch-all.module.css b/app/styles/catch-all.module.css index c736c5b866f..4f4919c42fe 100644 --- a/app/styles/catch-all.module.css +++ b/app/styles/catch-all.module.css @@ -18,4 +18,9 @@ composes: button-reset from '../styles/shared/buttons.module.css'; composes: link from '../styles/application.module.css'; font-weight: 500; + + &[disabled] { + color: var(--grey600); + cursor: wait; + } } diff --git a/app/templates/catch-all.hbs b/app/templates/catch-all.hbs index e898155870b..a9e39ba14de 100644 --- a/app/templates/catch-all.hbs +++ b/app/templates/catch-all.hbs @@ -4,7 +4,17 @@

{{or @model.title "Page not found"}}

- {{#if @model.tryAgain}} + {{#if @model.loginNeeded}} + + {{else if @model.tryAgain}} {{else}} diff --git a/tests/acceptance/dashboard-test.js b/tests/acceptance/dashboard-test.js index 2980524fa4e..45eefd84242 100644 --- a/tests/acceptance/dashboard-test.js +++ b/tests/acceptance/dashboard-test.js @@ -10,10 +10,11 @@ import { visit } from '../helpers/visit-ignoring-abort'; module('Acceptance | Dashboard', function (hooks) { setupApplicationTest(hooks); - test('redirects to / when not logged in', async function (assert) { + test('shows "page requires authentication" error when not logged in', async function (assert) { await visit('/dashboard'); - assert.equal(currentURL(), '/'); - assert.dom('[data-test-notification-message]').hasText('Please log in to proceed'); + assert.equal(currentURL(), '/dashboard'); + assert.dom('[data-test-title]').hasText('This page requires authentication'); + assert.dom('[data-test-login]').exists(); }); test('shows the dashboard when logged in', async function (assert) { diff --git a/tests/acceptance/invites-test.js b/tests/acceptance/invites-test.js index 1d2513d8bf4..5ec95d143ea 100644 --- a/tests/acceptance/invites-test.js +++ b/tests/acceptance/invites-test.js @@ -40,10 +40,11 @@ module('Acceptance | /me/pending-invites', function (hooks) { return { nanomsg, user }; } - test('redirects to / when not logged in', async function (assert) { + test('shows "page requires authentication" error when not logged in', async function (assert) { await visit('/me/pending-invites'); - assert.equal(currentURL(), '/'); - assert.dom('[data-test-notification-message]').hasText('Please log in to proceed'); + assert.equal(currentURL(), '/me/pending-invites'); + assert.dom('[data-test-title]').hasText('This page requires authentication'); + assert.dom('[data-test-login]').exists(); }); test('list all pending crate owner invites', async function (assert) {