James Moger
2013-09-18 0250286553ca93406bfaa976d6aae61e76a9d55f
src/main/java/com/gitblit/models/UserModel.java
@@ -35,6 +35,7 @@
import com.gitblit.Constants.RegistrantType;
import com.gitblit.Constants.Unused;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ModelUtils;
import com.gitblit.utils.StringUtils;
/**
@@ -75,17 +76,21 @@
   // non-persisted fields
   public boolean isAuthenticated;
   public AccountType accountType;
   public UserPreferences userPreferences;
   
   public UserModel(String username) {
      this.username = username;
      this.isAuthenticated = true;
      this.accountType = AccountType.LOCAL;
      this.userPreferences = new UserPreferences(this.username);
   }
   private UserModel() {
      this.username = "$anonymous";
      this.isAuthenticated = false;
      this.accountType = AccountType.LOCAL;
      this.userPreferences = new UserPreferences(this.username);
   }
   
   public boolean isLocalAccount() {
@@ -269,7 +274,13 @@
   }
      
   public void setRepositoryPermission(String repository, AccessPermission permission) {
      permissions.put(repository.toLowerCase(), permission);
      if (permission == null) {
         // remove the permission
         permissions.remove(repository.toLowerCase());
      } else {
         // set the new permission
         permissions.put(repository.toLowerCase(), permission);
      }
   }
   public RegistrantAccessPermission getRepositoryPermission(RepositoryModel repository) {
@@ -557,7 +568,7 @@
      }
      if (canCreate) {
         String projectPath = StringUtils.getFirstPathElement(repository);
         if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username)) {
         if (!StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath())) {
            // personal repository
            return true;
         }
@@ -599,7 +610,11 @@
   }
   
   public String getPersonalPath() {
      return "~" + username;
      return ModelUtils.getPersonalPath(username);
   }
   public UserPreferences getPreferences() {
      return userPreferences;
   }
   
   @Override
@@ -661,6 +676,6 @@
   
   public boolean isMyPersonalRepository(String repository) {
      String projectPath = StringUtils.getFirstPathElement(repository);
      return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase("~" + username);
      return !StringUtils.isEmpty(projectPath) && projectPath.equalsIgnoreCase(getPersonalPath());
   }
}