Compatible with the webclient again. Full audit REQUIRED.
This commit is contained in:
parent
40fcc9c66e
commit
a888551bbc
3 changed files with 9 additions and 8 deletions
src
|
@ -69,7 +69,8 @@ class DNSManager::Request
|
||||||
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
|
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
|
||||||
user = dnsmanagerd.get_logged_user event
|
user = dnsmanagerd.get_logged_user event
|
||||||
return Response::ErrorUserNotLogged.new unless user
|
return Response::ErrorUserNotLogged.new unless user
|
||||||
Response::DomainList.new dnsmanagerd.storage.user_domains user.uid
|
user_domain_names = dnsmanagerd.storage.user_domains(user.uid).map &.name
|
||||||
|
Response::DomainList.new user_domain_names
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
DNSManager.requests << UserDomains
|
DNSManager.requests << UserDomains
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
class DNSManager::Response
|
class DNSManager::Response
|
||||||
IPC::JSON.message DomainDeleted, 9 do
|
IPC::JSON.message DomainDeleted, 9 do
|
||||||
property domain : String
|
property domain : String
|
||||||
|
@ -52,7 +51,7 @@ class DNSManager::Response
|
||||||
IPC::JSON.message Logged, 16 do
|
IPC::JSON.message Logged, 16 do
|
||||||
property admin : Bool
|
property admin : Bool
|
||||||
property accepted_domains : Array(String)
|
property accepted_domains : Array(String)
|
||||||
property my_domains : Array(String)
|
property my_domains : Array(DNSManager::Storage::Domain)
|
||||||
def initialize(@admin, @accepted_domains, @my_domains)
|
def initialize(@admin, @accepted_domains, @my_domains)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -119,4 +118,3 @@ class DNSManager::Response
|
||||||
end
|
end
|
||||||
DNSManager.responses << OrphanDomainList
|
DNSManager.responses << OrphanDomainList
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,9 @@ class DNSManager::Storage
|
||||||
#
|
#
|
||||||
|
|
||||||
# Add the new domain.
|
# Add the new domain.
|
||||||
@domains << Domain.new domain, owners: [user_id]
|
the_new_domain = Domain.new domain
|
||||||
|
the_new_domain.owners = [user_id]
|
||||||
|
@domains << the_new_domain
|
||||||
|
|
||||||
# Add the new zone in the database.
|
# Add the new zone in the database.
|
||||||
zones_by_domain.update_or_create domain, default_zone
|
zones_by_domain.update_or_create domain, default_zone
|
||||||
|
@ -324,9 +326,9 @@ class DNSManager::Storage
|
||||||
Response::Success.new
|
Response::Success.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_domains(user_id : UserDataID) : Array(String)
|
def user_domains(user_id : UserDataID) : Array(Domain)
|
||||||
user_must_exist! user_id
|
user_must_exist! user_id
|
||||||
domains_by_owners.get(user_id.to_s).map &.name
|
domains_by_owners.get(user_id.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: is the user known from authd?
|
# TODO: is the user known from authd?
|
||||||
|
@ -346,7 +348,7 @@ class DNSManager::Storage
|
||||||
|
|
||||||
# Owning a domain means to be in the owners' list of the domain.
|
# Owning a domain means to be in the owners' list of the domain.
|
||||||
# TODO: accept admin users to override this test.
|
# TODO: accept admin users to override this test.
|
||||||
def user_should_own!(user_id : UserDataID, domain : String)
|
def user_should_own!(user_id : UserDataID, domain : String) : Nil
|
||||||
d = domains_by_name.get domain
|
d = domains_by_name.get domain
|
||||||
unless d.owners.includes? user_id
|
unless d.owners.includes? user_id
|
||||||
raise NoOwnershipException.new
|
raise NoOwnershipException.new
|
||||||
|
|
Loading…
Add table
Reference in a new issue