encryptable_attributes 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 173da0884b157d5b7280612abb975c6a2450605b8ff3f2b725a2a5db5d459c7f
4
- data.tar.gz: d2e9f24ee9296a10ef216e8335f9b4e512c0f3200e2ae15dcf7f04c8f77ae3ad
3
+ metadata.gz: 8c6d83bb5c347f07d499a7738d2f5d49444344528b652ee9a4fc24f430731833
4
+ data.tar.gz: 61631e757abd27db494581e09f4f863c870c87b7c7f809bfef7c7655ca88ef04
5
5
  SHA512:
6
- metadata.gz: 7e82ff723ab8ad2779e8d97f47c556a6ba160e91d1876aca27996bf655337e7347d864eae146e986f4c939d4f59ecb53b825fd70a1c35ff4bcec2711722e084d
7
- data.tar.gz: 70476d5be41cc2bbdc424ef135d7190ffd7a85a6a003fd6fff9a1d03c5a0180088932a128b69f19f34688a17ec547506e0c69c26ca3c65ff6103c071c589f266
6
+ metadata.gz: '0885d409873ab3025564aac978bd62c03d6b8bb95f8525890c3da22c1f483ec77143c0baf5f5dc8089391b052565c668a5c092024a4cd799ecada3f05deb8ff7'
7
+ data.tar.gz: e3c7170468111d1b19b51734916d6e98650ef5c0e6fe2c9a5c278a293d4c8888815f0d2a40b05411f34d48a38c5d99e6d967188b14ae287314b02b20d09cc2f3
@@ -1,3 +1,6 @@
1
+ ## EncryptableAttributes 0.2.2 (May 20, 2018)
2
+ * *FIX*: Don't try to encrypt and decrypt blank values (nil)
3
+
1
4
  ## EncryptableAttributes 0.2.1 (May 13, 2018)
2
5
  * *FIX*: Rotate `ActiveSupport::MessageEncryptor` keys to ensure they are kept in case new configs are added
3
6
  * Added active_record as runtime dependency
@@ -28,11 +28,23 @@ module EncryptableAttributes
28
28
  def secure_attrs(*attr_names)
29
29
  attr_names.each do |attr_name|
30
30
  define_method :"#{attr_name}=" do |value|
31
- write_attribute(attr_name, crypt.encrypt_and_sign(value))
31
+ if value.present?
32
+ write_attribute(attr_name, crypt.encrypt_and_sign(value))
33
+ else
34
+ # Allow to 'clear' attributes with nil
35
+ write_attribute(attr_name, value)
36
+ end
32
37
  end
33
38
 
34
39
  define_method :"#{attr_name}" do
35
- crypt.decrypt_and_verify(read_attribute(attr_name))
40
+ possibly_encrypted_value = read_attribute(attr_name)
41
+
42
+ if possibly_encrypted_value.present?
43
+ crypt.decrypt_and_verify(possibly_encrypted_value)
44
+ else
45
+ # Don't try to decrypt blank fields (nil)
46
+ possibly_encrypted_value
47
+ end
36
48
  end
37
49
  end
38
50
  end
@@ -1,3 +1,3 @@
1
1
  module EncryptableAttributes
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encryptable_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Sommer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-13 00:00:00.000000000 Z
11
+ date: 2018-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport