From ea9526d456219a063296ddce2f29c9de802ffa8c Mon Sep 17 00:00:00 2001 From: "kaspars.kurms" Date: Mon, 11 Jul 2016 12:55:21 +0300 Subject: [PATCH] fix user effective permission display if users is in multiple groups with different permissions --- src/main/java/com/gitblit/models/UserModel.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/gitblit/models/UserModel.java b/src/main/java/com/gitblit/models/UserModel.java index 1d9e413b..1d95569f 100644 --- a/src/main/java/com/gitblit/models/UserModel.java +++ b/src/main/java/com/gitblit/models/UserModel.java @@ -136,6 +136,7 @@ public class UserModel implements Principal, Serializable, Comparable // include immutable team permissions, being careful to preserve order Set set = new LinkedHashSet(list); + ArrayList arrayList = new ArrayList(list); for (TeamModel team : teams) { for (RegistrantAccessPermission teamPermission : team.getRepositoryPermissions()) { // we can not change an inherited team permission, though we can override @@ -143,6 +144,18 @@ public class UserModel implements Principal, Serializable, Comparable teamPermission.permissionType = PermissionType.TEAM; teamPermission.source = team.name; teamPermission.mutable = false; + if(arrayList.contains(teamPermission) && arrayList.get(arrayList.indexOf(teamPermission)).permissionType != PermissionType.REGEX){ + //checking either to replace permission in set or not + if(teamPermission.permission.compareTo(arrayList.get(arrayList.indexOf(teamPermission)).permission) > 0 ){ + arrayList.remove(teamPermission); + arrayList.add(teamPermission); + set.remove(teamPermission); + set.add(teamPermission); + } + } + else{ + arrayList.add(teamPermission); + } set.add(teamPermission); } } -- 2.39.5