]> source.dussan.org Git - gitblit.git/commitdiff
fix user effective permission display if users is in multiple groups with different...
authorkaspars.kurms <kaspars.kurms@ctco.lv>
Mon, 11 Jul 2016 09:55:21 +0000 (12:55 +0300)
committerFlorian Zschocke <f.zschocke+git@gmail.com>
Sun, 7 Aug 2022 11:35:34 +0000 (13:35 +0200)
src/main/java/com/gitblit/models/UserModel.java

index 1d9e413bb869c7a4d7baf6202b41c05d83053403..1d95569f9b85ff8dae0b678b20ce92f3890940df 100644 (file)
@@ -136,6 +136,7 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
 \r
                // include immutable team permissions, being careful to preserve order\r
                Set<RegistrantAccessPermission> set = new LinkedHashSet<RegistrantAccessPermission>(list);\r
+               ArrayList<RegistrantAccessPermission> arrayList = new ArrayList<RegistrantAccessPermission>(list);\r
                for (TeamModel team : teams) {\r
                        for (RegistrantAccessPermission teamPermission : team.getRepositoryPermissions()) {\r
                                // we can not change an inherited team permission, though we can override\r
@@ -143,6 +144,18 @@ public class UserModel implements Principal, Serializable, Comparable<UserModel>
                                teamPermission.permissionType = PermissionType.TEAM;\r
                                teamPermission.source = team.name;\r
                                teamPermission.mutable = false;\r
+                if(arrayList.contains(teamPermission) && arrayList.get(arrayList.indexOf(teamPermission)).permissionType != PermissionType.REGEX){\r
+                    //checking either to replace permission in set or not\r
+                    if(teamPermission.permission.compareTo(arrayList.get(arrayList.indexOf(teamPermission)).permission) > 0 ){\r
+                        arrayList.remove(teamPermission);\r
+                        arrayList.add(teamPermission);\r
+                        set.remove(teamPermission);\r
+                        set.add(teamPermission);\r
+                    }\r
+                }\r
+                else{\r
+                    arrayList.add(teamPermission);\r
+                }\r
                                set.add(teamPermission);\r
                        }\r
                }\r