class Decidim::NewsletterEncryptor
Public Class Methods
crypt_data()
click to toggle source
# File lib/decidim/newsletter_encryptor.rb, line 15 def self.crypt_data key = ActiveSupport::KeyGenerator.new("sent_at").generate_key( Rails.application.secrets.secret_key_base, ActiveSupport::MessageEncryptor.key_len ) ActiveSupport::MessageEncryptor.new(key) end
sent_at_decrypted(string_encrypted)
click to toggle source
Method to decrypt sent_at newsletter.
# File lib/decidim/newsletter_encryptor.rb, line 11 def self.sent_at_decrypted(string_encrypted) crypt_data.decrypt_and_verify(string_encrypted) end
sent_at_encrypted(user_id, sent_at)
click to toggle source
Method to create string encrypt using sent_at time to unsubscribe's user
# File lib/decidim/newsletter_encryptor.rb, line 6 def self.sent_at_encrypted(user_id, sent_at) crypt_data.encrypt_and_sign("#{user_id}-#{sent_at.to_i}") end