mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 21:16:26 +01:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									f8b21ac04a
								
							
						
					
					
						commit
						ae0d8d94df
					
				@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user