From 58f83d4d5cfe7cad2f0cfd13b0db8674a840c71f Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sun, 17 Nov 2024 01:17:17 +0100 Subject: [PATCH] Transfer token removed once share token is generated. --- src/storage.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/storage.cr b/src/storage.cr index 1dfe036..0715f8d 100644 --- a/src/storage.cr +++ b/src/storage.cr @@ -176,8 +176,11 @@ class DNSManager::Storage domain = @domains_by_name.get domain_name if domain.share_key.nil? - # Clone the domain so the database doesn't try to remove the new `shared_key`. + # Clone the domain so the database doesn't try to remove the new `share_key`. domain_cloned = domain.clone + + # Sharing the domain cancels domain transfer. + domain_cloned.transfer_key = nil domain_cloned.share_key = UUID.random.to_s @domains_by_name.update domain_name, domain_cloned Response::DomainChanged.new domain_cloned @@ -192,6 +195,9 @@ class DNSManager::Storage domain = @domains_by_name.get domain_name if domain.transfer_key.nil? + # You cannot transfer the domain in case it has a share key. + return Response::Error.new "The domain has a share key." unless domain.share_key.nil? + # Clone the domain so the database doesn't try to remove the new `transfer_key`. domain_cloned = domain.clone domain_cloned.transfer_key = UUID.random.to_s @@ -209,7 +215,7 @@ class DNSManager::Storage domain = @domains_by_name.get domain_name if domain.owners.size == 1 && domain.owners[0] == user_id - # Clone the domain so the old `shared_key` still exists in the old version. + # Clone the domain so the old `share_key` still exists in the old version. domain_cloned = domain.clone domain_cloned.share_key = nil @domains_by_name.update domain_cloned