From ec0ce1621a3e145d5786c0c26caffd0c5c3acd61 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 3 Oct 2012 17:50:48 -0400 Subject: [PATCH] Fix anonymous browsing of user profile page --- src/com/gitblit/models/RepositoryModel.java | 4 ++++ src/com/gitblit/models/UserModel.java | 2 +- src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/gitblit/models/RepositoryModel.java b/src/com/gitblit/models/RepositoryModel.java index 65629faf..caf7e7e4 100644 --- a/src/com/gitblit/models/RepositoryModel.java +++ b/src/com/gitblit/models/RepositoryModel.java @@ -152,6 +152,10 @@ public class RepositoryModel implements Serializable, Comparable } private UserModel() { - this.username = "anonymous"; + this.username = "$anonymous"; this.isAuthenticated = false; } diff --git a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java index 0a6bc623..50f0d52d 100644 --- a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java +++ b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java @@ -134,8 +134,11 @@ public class ProjectRepositoryPanel extends BasePanel { } UserModel user = GitBlitWebSession.get().getUser(); + if (user == null) { + user = UserModel.ANONYMOUS; + } Fragment repositoryLinks; - boolean showOwner = user != null && user.username.equalsIgnoreCase(entry.owner); + boolean showOwner = entry.isOwner(user.username); // owner of personal repository gets admin powers boolean showAdmin = isAdmin || entry.isUsersPersonalRepository(user.username); -- 2.39.5