]> source.dussan.org Git - gitblit.git/commitdiff
Fix anonymous browsing of user profile page
authorJames Moger <james.moger@gitblit.com>
Wed, 3 Oct 2012 21:50:48 +0000 (17:50 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 3 Oct 2012 21:50:48 +0000 (17:50 -0400)
src/com/gitblit/models/RepositoryModel.java
src/com/gitblit/models/UserModel.java
src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java

index 65629fafbb36b4be816825110389d9492d5f6498..caf7e7e4b889bf6b6722dff05552a25a4c045d88 100644 (file)
@@ -152,6 +152,10 @@ public class RepositoryModel implements Serializable, Comparable<RepositoryModel
                return !StringUtils.isEmpty(originRepository);\r
        }\r
        \r
+       public boolean isOwner(String username) {\r
+               return owner != null && username != null && owner.equalsIgnoreCase(username);\r
+       }\r
+       \r
        public boolean isPersonalRepository() {\r
                return !StringUtils.isEmpty(projectPath) && projectPath.charAt(0) == '~';\r
        }\r
index 6d5de3bb4b7195ab0e6525a3860d35bc9969d9c5..dd41df08ebc23d246102f132a341586242189074 100644 (file)
@@ -59,7 +59,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
        }\r
 \r
        private UserModel() {\r
-               this.username = "anonymous";\r
+               this.username = "$anonymous";\r
                this.isAuthenticated = false;\r
        }\r
 \r
index 0a6bc62368e1e83dee4c435657b4d861adea37a8..50f0d52d2aefebe7b8d3d3fa4a0b76a5821071af 100644 (file)
@@ -134,8 +134,11 @@ public class ProjectRepositoryPanel extends BasePanel {
                }\r
 \r
                UserModel user = GitBlitWebSession.get().getUser();\r
+               if (user == null) {\r
+                       user = UserModel.ANONYMOUS;\r
+               }\r
                Fragment repositoryLinks;\r
-               boolean showOwner = user != null && user.username.equalsIgnoreCase(entry.owner);\r
+               boolean showOwner = entry.isOwner(user.username);\r
                // owner of personal repository gets admin powers\r
                boolean showAdmin = isAdmin || entry.isUsersPersonalRepository(user.username);\r
 \r