Skip to content

fix not respecting landing page setting #4209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions integrations/setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,25 @@ func TestSettingShowUserEmailProfile(t *testing.T) {

setting.UI.ShowUserEmail = showUserEmail
}

func TestSettingLandingPage(t *testing.T) {
prepareTestEnv(t)

landingPage := setting.LandingPageURL

setting.LandingPageURL = setting.LandingPageHome
req := NewRequest(t, "GET", "/")
MakeRequest(t, req, http.StatusOK)

setting.LandingPageURL = setting.LandingPageExplore
req = NewRequest(t, "GET", "/")
resp := MakeRequest(t, req, http.StatusFound)
assert.Equal(t, "/explore", resp.Header().Get("Location"))

setting.LandingPageURL = setting.LandingPageOrganizations
req = NewRequest(t, "GET", "/")
resp = MakeRequest(t, req, http.StatusFound)
assert.Equal(t, "/explore/organizations", resp.Header().Get("Location"))

setting.LandingPageURL = landingPage
}
6 changes: 0 additions & 6 deletions modules/context/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ func Toggle(options *ToggleOptions) macaron.Handler {
return
}

// Check non-logged users landing page.
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LandingPageHome {
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageURL))
return
}

// Redirect to dashboard if user tries to visit any non-login page.
if options.SignOutRequired && ctx.IsSigned && ctx.Req.RequestURI != "/" {
ctx.Redirect(setting.AppSubURL + "/")
Expand Down
4 changes: 4 additions & 0 deletions routers/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func Home(ctx *context.Context) {
user.Dashboard(ctx)
}
return
// Check non-logged users landing page.
} else if setting.LandingPageURL != setting.LandingPageHome {
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageURL))
return
}

// Check auto-login.
Expand Down