]> source.dussan.org Git - gitblit.git/commitdiff
Use anonymous usermodel in a few places
authorJames Moger <james.moger@gitblit.com>
Wed, 3 Oct 2012 21:13:31 +0000 (17:13 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 3 Oct 2012 21:13:31 +0000 (17:13 -0400)
src/com/gitblit/models/UserModel.java
src/com/gitblit/wicket/pages/RepositoryPage.java

index 7c32a5556e5129ffd800ca2299c4f9279f2196f1..6d5de3bb4b7195ab0e6525a3860d35bc9969d9c5 100644 (file)
@@ -36,7 +36,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
 \r
        private static final long serialVersionUID = 1L;\r
 \r
-       public static final UserModel ANONYMOUS = new UserModel("anonymous", false);\r
+       public static final UserModel ANONYMOUS = new UserModel();\r
        \r
        // field names are reflectively mapped in EditUser page\r
        public String username;\r
@@ -58,9 +58,9 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                this.isAuthenticated = true;\r
        }\r
 \r
-       private UserModel(String username, boolean authenticated) {\r
-               this.username = username;\r
-               this.isAuthenticated = authenticated;\r
+       private UserModel() {\r
+               this.username = "anonymous";\r
+               this.isAuthenticated = false;\r
        }\r
 \r
        /**\r
index 879c43212a9525e8433820f041554cee7476cc90..2afc2c4d9f4f3e24e93be3f18f4edf3e696033e7 100644 (file)
@@ -196,6 +196,9 @@ public abstract class RepositoryPage extends BasePage {
                add(new Label("pageName", pageName).setRenderBodyOnly(true));\r
                \r
                UserModel user = GitBlitWebSession.get().getUser();\r
+               if (user == null) {\r
+                       user = UserModel.ANONYMOUS;\r
+               }\r
 \r
                // indicate origin repository\r
                RepositoryModel model = getRepositoryModel();\r
@@ -231,7 +234,7 @@ public abstract class RepositoryPage extends BasePage {
                }\r
 \r
                // fork controls\r
-               if (!allowForkControls() || user == null) {\r
+               if (!allowForkControls() || user == null || !user.isAuthenticated) {\r
                        // must be logged-in to fork, hide all fork controls\r
                        add(new ExternalLink("forkLink", "").setVisible(false));\r
                        add(new ExternalLink("myForkLink", "").setVisible(false));\r