Skip to content

Commit cc7cacc

Browse files
author
Gusted
committed
Let MinUnitAccessMode return correct perm
- 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 go-gitea#18572 (Point 1,2,5?)
1 parent c14ca34 commit cc7cacc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

models/unit/unit.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,12 @@ func AllUnitKeyNames() []string {
328328
// MinUnitAccessMode returns the minial permission of the permission map
329329
func MinUnitAccessMode(unitsMap map[Type]perm.AccessMode) perm.AccessMode {
330330
res := perm.AccessModeNone
331-
for _, mode := range unitsMap {
331+
for t, mode := range unitsMap {
332+
// Don't allow `TypeExternal{Tracker,Wiki}` to influence this as they can only be set to READ perms.
333+
if t == TypeExternalTracker || t == TypeExternalWiki {
334+
continue
335+
}
336+
332337
// get the minial permission great than AccessModeNone except all are AccessModeNone
333338
if mode > perm.AccessModeNone && (res == perm.AccessModeNone || mode < res) {
334339
res = mode

0 commit comments

Comments
 (0)