aboutsummaryrefslogtreecommitdiffstats
path: root/models/unit
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-02-08 22:16:17 +0100
committerGitHub <noreply@github.com>2022-02-08 21:16:17 +0000
commitae0d8d94dfc896800805d2f0226a8c347cb97793 (patch)
treeaafc18090b5dd08ab198c8f056b6c50775294c20 /models/unit
parentf8b21ac04a02a784fe14941e5c89940448694b8c (diff)
downloadgitea-ae0d8d94dfc896800805d2f0226a8c347cb97793.tar.gz
gitea-ae0d8d94dfc896800805d2f0226a8c347cb97793.zip
Let `MinUnitAccessMode` return correct perm (#18675)
- Don't let `TypeExternalTracker` or `TypeExternalWiki` influence the minimal permission, as they won't be higher than read. So even if all the other ones are write, these 2 will ensure that's not higher than read. - Partially resolves #18572 (Point 1,2,5?) Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/unit')
-rw-r--r--models/unit/unit.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/models/unit/unit.go b/models/unit/unit.go
index eb71276786..a6a47eb1f3 100644
--- a/models/unit/unit.go
+++ b/models/unit/unit.go
@@ -328,7 +328,12 @@ func AllUnitKeyNames() []string {
// MinUnitAccessMode returns the minial permission of the permission map
func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode {
res := perm.AccessModeNone
- for _, mode := range unitsMap {
+ for t, mode := range unitsMap {
+ // Don't allow `TypeExternal{Tracker,Wiki}` to influence this as they can only be set to READ perms.
+ if t == TypeExternalTracker || t == TypeExternalWiki {
+ continue
+ }
+
// get the minial permission great than AccessModeNone except all are AccessModeNone
if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) {
res = mode