diff --git a/src/requests/login.cr b/src/requests/login.cr index ec011eb..59a754a 100644 --- a/src/requests/login.cr +++ b/src/requests/login.cr @@ -14,7 +14,12 @@ class DNSManager::Request #dnsmanagerd.auth.edit_profile_content user.uid, { # "dnsmanager-last-connection" => JSON::Any.new Time.utc.to_s #} - dnsmanagerd.storage.ensure_user_data response.user.uid + user_data = dnsmanagerd.storage.ensure_user_data response.user.uid + return Response::Error.new "invalid user" unless user_data + + accepted_domains = dnsmanagerd.configuration.accepted_domains.not_nil! + user_domains = user_data.domains + Response::Logged.new accepted_domains, user_domains else Response::ErrorInvalidToken.new end diff --git a/src/responses/zone.cr b/src/responses/zone.cr index ba5b33f..89bf3e0 100644 --- a/src/responses/zone.cr +++ b/src/responses/zone.cr @@ -34,5 +34,27 @@ class DNSManager::Response end end DNSManager.responses << DomainList + + IPC::JSON.message AcceptedDomains, 15 do + property domains : Array(String) + def initialize(@domains) + end + end + DNSManager.responses << AcceptedDomains + + IPC::JSON.message Logged, 16 do + property accepted_domains : Array(String) + property my_domains : Array(String) + def initialize(@accepted_domains, @my_domains) + end + end + DNSManager.responses << Logged + + IPC::JSON.message DomainAdded, 17 do + property domain : String + def initialize(@domain) + end + end + DNSManager.responses << DomainAdded end diff --git a/src/storage.cr b/src/storage.cr index 5bad526..6c7e3f3 100644 --- a/src/storage.cr +++ b/src/storage.cr @@ -51,7 +51,7 @@ class DNSManager::Storage @user_data << UserData.new user_id end - Response::Success.new + user_data end def new_domain(accepted_domains : Array(String), @@ -100,7 +100,7 @@ class DNSManager::Storage # Add the new zone in the database. zones_by_domain.update_or_create domain, default_zone - Response::Success.new + Response::DomainAdded.new domain end def add_or_update_zone(user_id : Int32, zone : Zone) : IPC::JSON