James Moger
2012-10-05 2c60de580f6452365a6f25c998b7dd1ca68f7181
src/com/gitblit/models/UserModel.java
@@ -36,6 +36,8 @@
   private static final long serialVersionUID = 1L;
   public static final UserModel ANONYMOUS = new UserModel();
   // field names are reflectively mapped in EditUser page
   public String username;
   public String password;
@@ -44,6 +46,7 @@
   public String emailAddress;
   public boolean canAdmin;
   public boolean canFork;
   public boolean canCreate;
   public boolean excludeFromFederation;
   public final Set<String> repositories = new HashSet<String>();
   public final Set<TeamModel> teams = new HashSet<TeamModel>();
@@ -54,6 +57,11 @@
   public UserModel(String username) {
      this.username = username;
      this.isAuthenticated = true;
   }
   private UserModel() {
      this.username = "$anonymous";
      this.isAuthenticated = false;
   }
   /**
@@ -84,6 +92,16 @@
         }
      }
      return false;
   }
   public boolean canViewRepository(RepositoryModel repository) {
      if (canAdmin) {
         return true;
      }
      if (repository.accessRestriction.atLeast(AccessRestrictionType.VIEW)) {
         return canAccessRepository(repository);
      }
      return true;
   }
   
   public boolean canForkRepository(RepositoryModel repository) {
@@ -157,6 +175,23 @@
      }
      return displayName;
   }
   public String getPersonalPath() {
      return "~" + username;
   }
   @Override
   public int hashCode() {
      return username.hashCode();
   }
   @Override
   public boolean equals(Object o) {
      if (o instanceof UserModel) {
         return username.equals(((UserModel) o).username);
      }
      return false;
   }
   @Override
   public String toString() {