From 4640f1b689684b805f08a5a937e91dfc65ae977f Mon Sep 17 00:00:00 2001 From: Hybris95 Date: Tue, 22 Apr 2014 12:23:03 +0200 Subject: [PATCH] Now only shows the "my tickets" button in the navbar if you are connected. Redirects to the main page if you try going on "/mytickets" when not connected (or if you disconnect while being on "/mytickets"). --- .../com/gitblit/wicket/pages/MyTicketsPage.java | 6 ++++-- .../java/com/gitblit/wicket/pages/RootPage.java | 17 +++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java index 2c57a051..9be3b125 100644 --- a/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/MyTicketsPage.java @@ -34,12 +34,14 @@ public class MyTicketsPage extends RootPage { public MyTicketsPage(PageParameters params) { - super(); + super(params); setupPage("", getString("gb.mytickets")); UserModel currentUser = GitBlitWebSession.get().getUser(); if (currentUser == null) { - currentUser = UserModel.ANONYMOUS; + setRedirect(true); + setResponsePage(getApplication().getHomePage()); + return; } String username = currentUser.getName(); diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java index ec413b19..a4d2353d 100644 --- a/src/main/java/com/gitblit/wicket/pages/RootPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java @@ -134,6 +134,8 @@ public abstract class RootPage extends BasePage { boolean authenticateView = app().settings().getBoolean(Keys.web.authenticateViewPages, false); boolean authenticateAdmin = app().settings().getBoolean(Keys.web.authenticateAdminPages, true); boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, true); + boolean allowLucene = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true); + boolean isLoggedIn = GitBlitWebSession.get().isLoggedIn(); if (authenticateAdmin) { showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); @@ -151,7 +153,7 @@ public abstract class RootPage extends BasePage { } if (authenticateView || authenticateAdmin) { - if (GitBlitWebSession.get().isLoggedIn()) { + if (isLoggedIn) { UserMenu userFragment = new UserMenu("userPanel", "userMenuFragment", RootPage.this); add(userFragment); } else { @@ -167,14 +169,17 @@ public abstract class RootPage extends BasePage { // navigation links List pages = new ArrayList(); - if (!authenticateView || (authenticateView && GitBlitWebSession.get().isLoggedIn())) { - pages.add(new PageRegistration(GitBlitWebSession.get().isLoggedIn() ? "gb.myDashboard" : "gb.dashboard", MyDashboardPage.class, + if (!authenticateView || (authenticateView && isLoggedIn)) { + pages.add(new PageRegistration(isLoggedIn ? "gb.myDashboard" : "gb.dashboard", MyDashboardPage.class, getRootPageParameters())); pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class, getRootPageParameters())); pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters())); - pages.add(new PageRegistration("gb.mytickets", MyTicketsPage.class, getRootPageParameters())); - if (app().settings().getBoolean(Keys.web.allowLuceneIndexing, true)) { + if(isLoggedIn) + { + pages.add(new PageRegistration("gb.mytickets", MyTicketsPage.class, getRootPageParameters())); + } + if (allowLucene) { pages.add(new PageRegistration("gb.search", LuceneSearchPage.class)); } if (showAdmin) { @@ -184,7 +189,7 @@ public abstract class RootPage extends BasePage { pages.add(new PageRegistration("gb.federation", FederationPage.class)); } - if (!authenticateView || (authenticateView && GitBlitWebSession.get().isLoggedIn())) { + if (!authenticateView || (authenticateView && isLoggedIn)) { addDropDownMenus(pages); } } -- 2.39.5