effective_resources 2.11.3 → 2.11.5
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 +4 -4
- data/app/models/concerns/acts_as_statused.rb +1 -1
- data/app/models/concerns/effective_devise_user.rb +22 -13
- data/lib/effective_resources/engine.rb +0 -2
- data/lib/effective_resources/version.rb +1 -1
- metadata +6 -6
- /data/{lib → app}/validators/boolean_validator.rb +0 -0
- /data/{lib → app}/validators/email_cc_validator.rb +0 -0
- /data/{lib → app}/validators/email_validator.rb +0 -0
- /data/{lib → app}/validators/url_validator.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0db1af1cd9888460bd6ba110a0d972925ad88c0221bc77d6fc98a15b44175b31
|
4
|
+
data.tar.gz: acb21c1d6a77daec5e2401ee22aa17b60005a46dfc708b06e8b1a5c0b5437196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a62c534e47770dda823fb51cc30834f1de229c61dae266d1de6f20031c6137ce57782c11f512d83a82bb0a90ca7983b439c94dd55298cdbba5466367d7e057a4
|
7
|
+
data.tar.gz: ade2cf04ecca9009abe9b2883252f5064843e83f76232d5ab8e51418370a0297bbe436ea83700d33c8840778cad272f0ffc447930fa10c631b92788c961aa3bc
|
@@ -48,12 +48,17 @@ module EffectiveDeviseUser
|
|
48
48
|
# Devise invitable ignores model validations, so we manually check for duplicate email addresses.
|
49
49
|
before_save(if: -> { new_record? && try(:invitation_sent_at).present? }) do
|
50
50
|
if email.blank?
|
51
|
-
|
51
|
+
errors.add(:email, "can't be blank")
|
52
52
|
raise("email can't be blank")
|
53
53
|
end
|
54
54
|
|
55
|
-
if self.class.where(email:
|
56
|
-
|
55
|
+
if self.class.where(email: value).present?
|
56
|
+
errors.add(:email, 'has already been taken')
|
57
|
+
raise("email has already been taken")
|
58
|
+
end
|
59
|
+
|
60
|
+
if respond_to?(:alternate_email) && self.class.where(alternate_email: value).present?
|
61
|
+
errors.add(:email, 'has already been taken')
|
57
62
|
raise("email has already been taken")
|
58
63
|
end
|
59
64
|
end
|
@@ -63,25 +68,29 @@ module EffectiveDeviseUser
|
|
63
68
|
assign_attributes(provider: nil, access_token: nil, refresh_token: nil, token_expires_at: nil)
|
64
69
|
end
|
65
70
|
|
71
|
+
validate(if: -> { email.present? && try(:alternate_email).present? }) do
|
72
|
+
errors.add(:alternate_email, 'cannot be the same as email') if email.strip.downcase == alternate_email.strip.downcase
|
73
|
+
end
|
74
|
+
|
66
75
|
# Uniqueness validation of emails and alternate emails across all users
|
67
76
|
validate(if: -> { respond_to?(:alternate_email) }) do
|
68
|
-
records = self.class.where.not(id:
|
69
|
-
email_duplicates = records.where("lower(email) = :email OR lower(alternate_email) = :email", email: email.to_s.strip.downcase)
|
70
|
-
alternate_email_duplicates = records.where("lower(email) = :alternate_email OR lower(alternate_email) = :alternate_email", alternate_email: alternate_email.to_s.strip.downcase)
|
77
|
+
records = self.class.where.not(id: id)
|
71
78
|
|
72
|
-
#
|
73
|
-
if !
|
74
|
-
|
79
|
+
# Validate email uniqueness
|
80
|
+
if (value = email.to_s.strip.downcase).present? && !errors.added?(:email, 'has already been taken')
|
81
|
+
existing = records.where("email = :value OR alternate_email = :value", value: value)
|
82
|
+
errors.add(:email, 'has already been taken') if existing.present?
|
75
83
|
end
|
76
84
|
|
77
|
-
#
|
78
|
-
if
|
79
|
-
|
85
|
+
# Validate alternate_email uniqueness
|
86
|
+
if (value = alternate_email.to_s.strip.downcase).present?
|
87
|
+
existing = records.where("email = :value OR alternate_email = :value", value: value)
|
88
|
+
errors.add(:alternate_email, 'has already been taken') if existing.present?
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
83
92
|
with_options(if: -> { respond_to?(:alternate_email) }) do
|
84
|
-
validates :alternate_email, email: true
|
93
|
+
validates :alternate_email, email: true
|
85
94
|
end
|
86
95
|
|
87
96
|
end
|
@@ -6,13 +6,11 @@ module EffectiveResources
|
|
6
6
|
|
7
7
|
config.autoload_paths += Dir[
|
8
8
|
"#{config.root}/jobs/",
|
9
|
-
"#{config.root}/lib/validators/",
|
10
9
|
"#{config.root}/app/controllers/concerns/"
|
11
10
|
]
|
12
11
|
|
13
12
|
config.eager_load_paths += Dir[
|
14
13
|
"#{config.root}/jobs/",
|
15
|
-
"#{config.root}/lib/validators/",
|
16
14
|
"#{config.root}/app/controllers/concerns/"
|
17
15
|
]
|
18
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -223,8 +223,12 @@ files:
|
|
223
223
|
- app/models/effective/resources/relation.rb
|
224
224
|
- app/models/effective/resources/sql.rb
|
225
225
|
- app/models/effective/resources/tenants.rb
|
226
|
+
- app/validators/boolean_validator.rb
|
226
227
|
- app/validators/content_type_validator.rb
|
228
|
+
- app/validators/email_cc_validator.rb
|
229
|
+
- app/validators/email_validator.rb
|
227
230
|
- app/validators/size_validator.rb
|
231
|
+
- app/validators/url_validator.rb
|
228
232
|
- app/views/application/_flash.html.haml
|
229
233
|
- app/views/application/create.js.erb
|
230
234
|
- app/views/application/destroy.js.erb
|
@@ -251,10 +255,6 @@ files:
|
|
251
255
|
- lib/effective_resources/engine.rb
|
252
256
|
- lib/effective_resources/version.rb
|
253
257
|
- lib/generators/effective_resources/install_generator.rb
|
254
|
-
- lib/validators/boolean_validator.rb
|
255
|
-
- lib/validators/email_cc_validator.rb
|
256
|
-
- lib/validators/email_validator.rb
|
257
|
-
- lib/validators/url_validator.rb
|
258
258
|
homepage: https://github.com/code-and-effect/effective_resources
|
259
259
|
licenses:
|
260
260
|
- MIT
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|