Transfer token removed once share token is generated.
This commit is contained in:
		
							parent
							
								
									4029ca7cd0
								
							
						
					
					
						commit
						58f83d4d5c
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -176,8 +176,11 @@ class DNSManager::Storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		domain = @domains_by_name.get domain_name
 | 
							domain = @domains_by_name.get domain_name
 | 
				
			||||||
		if domain.share_key.nil?
 | 
							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
 | 
								domain_cloned = domain.clone
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								# Sharing the domain cancels domain transfer.
 | 
				
			||||||
 | 
								domain_cloned.transfer_key = nil
 | 
				
			||||||
			domain_cloned.share_key = UUID.random.to_s
 | 
								domain_cloned.share_key = UUID.random.to_s
 | 
				
			||||||
			@domains_by_name.update domain_name, domain_cloned
 | 
								@domains_by_name.update domain_name, domain_cloned
 | 
				
			||||||
			Response::DomainChanged.new domain_cloned
 | 
								Response::DomainChanged.new domain_cloned
 | 
				
			||||||
| 
						 | 
					@ -192,6 +195,9 @@ class DNSManager::Storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		domain = @domains_by_name.get domain_name
 | 
							domain = @domains_by_name.get domain_name
 | 
				
			||||||
		if domain.transfer_key.nil?
 | 
							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`.
 | 
								# Clone the domain so the database doesn't try to remove the new `transfer_key`.
 | 
				
			||||||
			domain_cloned = domain.clone
 | 
								domain_cloned = domain.clone
 | 
				
			||||||
			domain_cloned.transfer_key = UUID.random.to_s
 | 
								domain_cloned.transfer_key = UUID.random.to_s
 | 
				
			||||||
| 
						 | 
					@ -209,7 +215,7 @@ class DNSManager::Storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		domain = @domains_by_name.get domain_name
 | 
							domain = @domains_by_name.get domain_name
 | 
				
			||||||
		if domain.owners.size == 1 && domain.owners[0] == user_id
 | 
							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 = domain.clone
 | 
				
			||||||
			domain_cloned.share_key = nil
 | 
								domain_cloned.share_key = nil
 | 
				
			||||||
			@domains_by_name.update domain_cloned
 | 
								@domains_by_name.update domain_cloned
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue