James Moger
2013-09-23 b2d7f418bf289e5fa6149ac1b5744cfb03b60dea
src/main/java/com/gitblit/ConfigUserService.java
@@ -92,6 +92,8 @@
   
   private static final String STARRED = "starred";
   
   private static final String LOCALE = "locale";
   private final File realmFile;
   private final Logger logger = LoggerFactory.getLogger(ConfigUserService.class);
@@ -184,8 +186,10 @@
      if (!StringUtils.isEmpty(model.cookie)) {
         return model.cookie;
      }
      read();
      UserModel storedModel = users.get(model.username.toLowerCase());
      UserModel storedModel = getUserModel(model.username);
      if (storedModel == null) {
         return null;
      }
      return storedModel.cookie;
   }
@@ -206,6 +210,12 @@
      if (cookies.containsKey(hash)) {
         model = cookies.get(hash);
      }
      if (model != null) {
         // clone the model, otherwise all changes to this object are
         // live and unpersisted
         model = DeepCopier.copy(model);
      }
      return model;
   }
@@ -218,7 +228,6 @@
    */
   @Override
   public UserModel authenticate(String username, char[] password) {
      read();
      UserModel returnedUser = null;
      UserModel user = getUserModel(username);
      if (user == null) {
@@ -849,6 +858,11 @@
         if (!StringUtils.isEmpty(model.countryCode)) {
            config.setString(USER, model.username, COUNTRYCODE, model.countryCode);
         }
         if (model.getPreferences() != null) {
            if (!StringUtils.isEmpty(model.getPreferences().locale)) {
               config.setString(USER, model.username, LOCALE, model.getPreferences().locale);
            }
         }
         // user roles
         List<String> roles = new ArrayList<String>();
@@ -1010,6 +1024,7 @@
               user.stateProvince = config.getString(USER, username, STATEPROVINCE);
               user.countryCode = config.getString(USER, username, COUNTRYCODE);
               user.cookie = config.getString(USER, username, COOKIE);
               user.getPreferences().locale = config.getString(USER, username, LOCALE);
               if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
                  user.cookie = StringUtils.getSHA1(user.username + user.password);
               }