lib/lockbox/active_storage_extensions.rb in lockbox-0.5.0 vs lib/lockbox/active_storage_extensions.rb in lockbox-0.6.0
- old
+ new
@@ -87,9 +87,13 @@
end
module CreateOne
def initialize(name, record, attachable)
# this won't encrypt existing blobs
+ # ideally we'd check metadata for the encrypted flag
+ # and disallow unencrypted blobs
+ # since they'll raise an error on decryption
+ # but earlier versions of Lockbox won't have it
attachable = Lockbox::Utils.encrypt_attachable(record, name, attachable) if Lockbox::Utils.encrypted?(record, name) && !attachable.is_a?(ActiveStorage::Blob)
super(name, record, attachable)
end
end