mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 18:07:30 +08:00
FIX: Redirect to default homepage when visiting /login
Previously this was hard-coded to redirect to `/latest`
This commit is contained in:
parent
ef7f84b59b
commit
071bd15463
|
@ -1,11 +1,12 @@
|
||||||
import buildStaticRoute from "discourse/routes/build-static-route";
|
import buildStaticRoute from "discourse/routes/build-static-route";
|
||||||
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
|
|
||||||
const LoginRoute = buildStaticRoute("login");
|
const LoginRoute = buildStaticRoute("login");
|
||||||
|
|
||||||
LoginRoute.reopen({
|
LoginRoute.reopen({
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
if (!this.siteSettings.login_required) {
|
if (!this.siteSettings.login_required) {
|
||||||
this.replaceWith("discovery.latest").then(e => {
|
this.replaceWith(`/${defaultHomepage()}`).then(e => {
|
||||||
Ember.run.next(() => e.send("showLogin"));
|
Ember.run.next(() => e.send("showLogin"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
20
test/javascripts/acceptance/login-redirect-test.js.es6
Normal file
20
test/javascripts/acceptance/login-redirect-test.js.es6
Normal file
|
@ -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"
|
||||||
|
);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user