From 61659013f64750a2bea217eb5e48b5365efe163f Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 3 Oct 2012 17:13:31 -0400 Subject: [PATCH] Use anonymous usermodel in a few places --- src/com/gitblit/models/UserModel.java | 8 ++++---- src/com/gitblit/wicket/pages/RepositoryPage.java | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/com/gitblit/models/UserModel.java b/src/com/gitblit/models/UserModel.java index 7c32a555..6d5de3bb 100644 --- a/src/com/gitblit/models/UserModel.java +++ b/src/com/gitblit/models/UserModel.java @@ -36,7 +36,7 @@ public class UserModel implements Principal, Serializable, Comparable private static final long serialVersionUID = 1L; - public static final UserModel ANONYMOUS = new UserModel("anonymous", false); + public static final UserModel ANONYMOUS = new UserModel(); // field names are reflectively mapped in EditUser page public String username; @@ -58,9 +58,9 @@ public class UserModel implements Principal, Serializable, Comparable this.isAuthenticated = true; } - private UserModel(String username, boolean authenticated) { - this.username = username; - this.isAuthenticated = authenticated; + private UserModel() { + this.username = "anonymous"; + this.isAuthenticated = false; } /** diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 879c4321..2afc2c4d 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -196,6 +196,9 @@ public abstract class RepositoryPage extends BasePage { add(new Label("pageName", pageName).setRenderBodyOnly(true)); UserModel user = GitBlitWebSession.get().getUser(); + if (user == null) { + user = UserModel.ANONYMOUS; + } // indicate origin repository RepositoryModel model = getRepositoryModel(); @@ -231,7 +234,7 @@ public abstract class RepositoryPage extends BasePage { } // fork controls - if (!allowForkControls() || user == null) { + if (!allowForkControls() || user == null || !user.isAuthenticated) { // must be logged-in to fork, hide all fork controls add(new ExternalLink("forkLink", "").setVisible(false)); add(new ExternalLink("myForkLink", "").setVisible(false)); -- 2.39.5