ErrorUserNotLogged

This commit is contained in:
Philippe Pittoli 2023-06-18 02:36:30 +02:00
parent ac9fc3b563
commit f0fdf75251
4 changed files with 19 additions and 9 deletions

View File

@ -13,6 +13,9 @@ class DNSManager::Request
end
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
return Response::ErrorUserNotLogged.new unless user
# This request means serious business.
# TODO: check for admin.

View File

@ -20,6 +20,7 @@ class DNSManager::Request
end
rescue e
# FIXME: Should those be logged?
Baguette::Log.error "Error: #{e}"
Response::Error.new "unauthorized"
end
end

View File

@ -11,7 +11,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.new_domain user.uid, @domain
end
end
@ -25,7 +25,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.add_or_update_zone user.uid, zone
end
end
@ -39,7 +39,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.delete_domain user.uid, @domain
end
end
@ -53,7 +53,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.get_zone user.uid, @domain
end
end
@ -65,7 +65,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.user_domains user.uid
end
end
@ -80,7 +80,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.add_rr user.uid, @domain, @rr
end
end
@ -95,7 +95,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.update_rr user.uid, @domain, @rr
end
end
@ -110,7 +110,7 @@ class DNSManager::Request
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
user = dnsmanagerd.get_logged_user event
raise NotLoggedException.new if user.nil?
return Response::ErrorUserNotLogged.new unless user
dnsmanagerd.storage.delete_rr user.uid, @domain, @rrid
end
end

View File

@ -17,5 +17,11 @@ class DNSManager::Response
def initialize()
end
end
DNSManager.responses << ErrorInvalidToken
DNSManager.responses << DomainAlreadyExists
IPC::JSON.message ErrorUserNotLogged, 4 do
def initialize()
end
end
DNSManager.responses << ErrorUserNotLogged
end