Commits

Sebastian Sdorra committed 71d1342

fix authentication bug in BasicSecurityContext

  • Participants
  • Parent commits 89caded

Comments (0)

Files changed (1)

scm-webapp/src/main/java/sonia/scm/web/security/BasicSecurityContext.java

 import sonia.scm.group.GroupManager;
 import sonia.scm.user.User;
 import sonia.scm.user.UserManager;
+import sonia.scm.util.Util;
 
 //~--- JDK imports ------------------------------------------------------------
 
       {
         User dbUser = userManager.get(username);
 
-        if ((dbUser != null) && dbUser.copyProperties(user, false))
+        if ((dbUser != null) && user.copyProperties(dbUser, false))
         {
           userManager.modify(dbUser);
         }
   {
     StringBuilder msg = new StringBuilder("user ");
 
-    msg.append(user.getName()).append(" is member of ");
+    msg.append(user.getName());
 
-    Iterator<String> groupIt = groups.iterator();
+    if (Util.isNotEmpty(groups))
+    {
+      msg.append(" is member of ");
 
-    while (groupIt.hasNext())
+      Iterator<String> groupIt = groups.iterator();
+
+      while (groupIt.hasNext())
+      {
+        msg.append(groupIt.next());
+
+        if (groupIt.hasNext())
+        {
+          msg.append(", ");
+        }
+      }
+    }
+    else
     {
-      msg.append(groupIt.next());
-
-      if (groupIt.hasNext())
-      {
-        msg.append(", ");
-      }
+      msg.append(" is not a memeber of a group");
     }
 
     logger.debug(msg.toString());