Some users can be administrators now.

This commit is contained in:
Philippe Pittoli 2023-05-08 21:38:39 +02:00
parent 35428314b5
commit 781a25debe
2 changed files with 9 additions and 7 deletions

View File

@ -71,7 +71,7 @@ class DNSManager::Storage
# Does the zone already exist?
if z = zones_by_domain.get? zone.domain
# User must own the zone.
unless user_data.domains.includes? zone.domain
unless user_data.domains.includes?(zone.domain) || user_data.admin
Baguette::Log.warning "user #{user_id} doesn't own domain #{zone.domain}"
return Response::NoOwnership.new
end
@ -107,7 +107,7 @@ class DNSManager::Storage
end
# User must own the zone.
unless user_data.domains.includes? domain
unless user_data.domains.includes?(domain) || user_data.admin
Baguette::Log.warning "user #{user_id} doesn't own domain #{domain}"
return Response::NoOwnership.new
end
@ -146,7 +146,7 @@ class DNSManager::Storage
end
# User must own the zone.
unless user_data.domains.includes? domain
unless user_data.domains.includes?(domain) || user_data.admin
Baguette::Log.warning "user #{user_id} doesn't own domain #{domain}"
return Response::NoOwnership.new
end
@ -185,7 +185,7 @@ class DNSManager::Storage
end
# User must own the zone.
unless user_data.domains.includes? domain
unless user_data.domains.includes?(domain) || user_data.admin
Baguette::Log.warning "user #{user_id} doesn't own domain #{domain}"
return Response::NoOwnership.new
end
@ -210,7 +210,7 @@ class DNSManager::Storage
end
# User must own the domain.
unless user_data.domains.includes? domain
unless user_data.domains.includes?(domain) || user_data.admin
Baguette::Log.warning "user #{user_id} tries to delete domain #{domain} but doesn't own it"
return Response::NoOwnership.new
end
@ -239,7 +239,7 @@ class DNSManager::Storage
end
# User must own the domain.
unless user_data.domains.includes? domain
unless user_data.domains.includes?(domain) || user_data.admin
Baguette::Log.warning "user #{user_id} tries to get zone #{domain} but doesn't own it"
return Response::NoOwnership.new
end

View File

@ -10,6 +10,8 @@ class DNSManager::Storage::UserData
# Users may have many domains, and a domain can have many owners.
property domains = [] of String
property admin : Bool = false
def initialize(@uid)
end
end