Move self destruct check to config_for and add constant for verifier string (#32943)
				
					
				
			This commit is contained in:
		@@ -1,9 +1,11 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
module SelfDestructHelper
 | 
			
		||||
  VERIFY_PURPOSE = 'self-destruct'
 | 
			
		||||
 | 
			
		||||
  def self.self_destruct?
 | 
			
		||||
    value = ENV.fetch('SELF_DESTRUCT', nil)
 | 
			
		||||
    value.present? && Rails.application.message_verifier('self-destruct').verify(value) == ENV['LOCAL_DOMAIN']
 | 
			
		||||
    value = Rails.configuration.x.mastodon.self_destruct_value
 | 
			
		||||
    value.present? && Rails.application.message_verifier(VERIFY_PURPOSE).verify(value) == ENV['LOCAL_DOMAIN']
 | 
			
		||||
  rescue ActiveSupport::MessageVerifier::InvalidSignature
 | 
			
		||||
    false
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user