better_record 0.10.3 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0869b2f98d02a23adb72e8b4bd858808b762192ebbb953c84807d8f462aa2da
|
4
|
+
data.tar.gz: 9ed06a0ca435e62a9ed2f66cb8b8164fa89d26688128cfed4b8f83ee0899e535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fb15f3111386f6ebef1516b61fe397976b29d9f2f87400ff311bfc5331c6a7371bfcc06ff011f3687ba273c856fbaeea5889b32f778360a06c56065b3ce381a
|
7
|
+
data.tar.gz: 2cfe923acd81309fb2bce64d01d85e9b8bca89ace312aeb3400bbbb7c34a6f05b9f86222706503c801c13780f6e1884325ac928c310695c2fd10e207b23567d9
|
@@ -32,6 +32,7 @@ module BetterRecord
|
|
32
32
|
# == Attributes ===========================================================
|
33
33
|
attribute :"new_#{password_field}", :text
|
34
34
|
attribute :"new_#{password_field}_confirmation", :text
|
35
|
+
attribute :"clear_#{password_field}", :boolean
|
35
36
|
|
36
37
|
# == Extensions ===========================================================
|
37
38
|
|
@@ -65,6 +66,15 @@ module BetterRecord
|
|
65
66
|
end
|
66
67
|
private :"#{password_field}="
|
67
68
|
|
69
|
+
define_method :"clear_#{password_field}=" do |value|
|
70
|
+
if value && (value.to_sym == :clear)
|
71
|
+
write_attribute password_field, (self.persisted? ? 'CLEAR_EXISTING_PASSWORD_FOR_ROW' : nil)
|
72
|
+
__send__ :"new_#{password_field}", nil
|
73
|
+
__send__ :"new_#{password_field}_confirmation", nil
|
74
|
+
end
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
68
78
|
define_method :"require_#{password_field}_confirmation" do
|
69
79
|
tmp_new_pwd = __send__ :"new_#{password_field}"
|
70
80
|
tmp_new_confirmation = __send__ :"new_#{password_field}_confirmation"
|
@@ -41,7 +41,11 @@ module BetterRecord
|
|
41
41
|
AND (
|
42
42
|
(TG_OP = 'INSERT') OR ( NEW.#{password_col} IS DISTINCT FROM OLD.#{password_col} )
|
43
43
|
) THEN
|
44
|
-
NEW.#{password_col}
|
44
|
+
IF (NEW.#{password_col} IS DISTINCT FROM 'CLEAR_EXISTING_PASSWORD_FOR_ROW') THEN
|
45
|
+
NEW.#{password_col} = hash_password(NEW.#{password_col});
|
46
|
+
ELSE
|
47
|
+
NEW.#{password_col} = NULL;
|
48
|
+
END IF;
|
45
49
|
ELSE
|
46
50
|
IF (TG_OP IS DISTINCT FROM 'INSERT') THEN
|
47
51
|
NEW.#{password_col} = OLD.#{password_col};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: better_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sampson Crowley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|