From 071bd15463fd0f9d695624d0cc82ccffa9efacf6 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 10 Dec 2018 15:39:05 +0000 Subject: [PATCH] FIX: Redirect to default homepage when visiting `/login` Previously this was hard-coded to redirect to `/latest` --- .../javascripts/discourse/routes/login.js.es6 | 3 ++- .../acceptance/login-redirect-test.js.es6 | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/javascripts/acceptance/login-redirect-test.js.es6 diff --git a/app/assets/javascripts/discourse/routes/login.js.es6 b/app/assets/javascripts/discourse/routes/login.js.es6 index 591b93af413..8465ceb6bcc 100644 --- a/app/assets/javascripts/discourse/routes/login.js.es6 +++ b/app/assets/javascripts/discourse/routes/login.js.es6 @@ -1,11 +1,12 @@ import buildStaticRoute from "discourse/routes/build-static-route"; +import { defaultHomepage } from "discourse/lib/utilities"; const LoginRoute = buildStaticRoute("login"); LoginRoute.reopen({ beforeModel() { if (!this.siteSettings.login_required) { - this.replaceWith("discovery.latest").then(e => { + this.replaceWith(`/${defaultHomepage()}`).then(e => { Ember.run.next(() => e.send("showLogin")); }); } diff --git a/test/javascripts/acceptance/login-redirect-test.js.es6 b/test/javascripts/acceptance/login-redirect-test.js.es6 new file mode 100644 index 00000000000..1d8a86fb024 --- /dev/null +++ b/test/javascripts/acceptance/login-redirect-test.js.es6 @@ -0,0 +1,20 @@ +import { acceptance } from "helpers/qunit-helpers"; + +acceptance("Login redirect", {}); + +QUnit.test("redirects categories to top", async assert => { + await visit("/login"); + assert.equal( + currentPath(), + "discovery.latest", + "it works when latest is the homepage" + ); + Discourse.SiteSettings.top_menu = "categories|latest|top|hot"; + + await visit("/login"); + assert.equal( + currentPath(), + "discovery.categories", + "it works when categories is the homepage" + ); +});