Commits

Sebastian Sdorra  committed fdc92e1

fix bug in isPrivileged method

  • Participants
  • Parent commits f798f1c

Comments (0)

Files changed (1)

File src/main/java/sonia/scm/branchwp/BranchWPPreReceiveRepositoryHook.java

 
     String type = repository.getType();
 
-    List<String> braches = changeset.getBranches();
+    List<String> branches = changeset.getBranches();
 
-    if (braches.isEmpty() && TYPE_GIT.equals(type))
+    if (branches.isEmpty() && TYPE_GIT.equals(type))
     {
       if (logger.isTraceEnabled())
       {
     {
       String username = context.getUser().getName();
 
-      String branch = getBranchName(type, braches);
+      String branch = getBranchName(type, branches);
+
+      if (logger.isTraceEnabled())
+      {
+        logger.trace("check write permission of user {} for branch {}",
+          username, branch);
+      }
 
       for (BranchWPPermission bwp : permissions)
       {
         //J-
-        if ((branch.equals(bwp.getBranch())
-           && (bwp.isGroup() && context.getGroups().contains(bwp.getName()))) 
-           || (!bwp.isGroup() && username.equals(bwp.getName())))
+        if (branch.equals(bwp.getBranch())
+           && ((bwp.isGroup() && context.getGroups().contains(bwp.getName()))
+           || (!bwp.isGroup() && username.equals(bwp.getName()))))
         {
           if ( logger.isTraceEnabled() )
           {
         //J+
       }
 
+      if (!privileged && logger.isWarnEnabled())
+      {
+        logger.warn("access denied for user {} at branch {}", username, branch);
+      }
+
     }
 
     return privileged;