effective_resources 2.11.4 → 2.11.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/effective_devise_user.rb +24 -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: df20052518286a1ff3271eddb3e9007211d31ac6702cc4bb87ddf0c6706a0a31
|
4
|
+
data.tar.gz: 15b0d4740305154619c1cf4922ed567811149c60966d63d2c737c6306a2b8e1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eccffe9230dd0ee3119e04c48cc8b05374d73d29ca18c7d5344c7d6be3cf39362622cadf17265b0f146773bd0be3dd77276b5988832d82c641c8c0f1f348a4c7
|
7
|
+
data.tar.gz: ab946a0050800cab2698955c69cdd27911ec110f7a68dacd19ef975b7800e2eadd1145c456f660d775b3f985d4e1e6a9f62776363191d78fae68f08ea0e81bb9
|
@@ -48,12 +48,19 @@ 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
|
-
|
56
|
-
|
55
|
+
value = email.strip.downcase
|
56
|
+
|
57
|
+
if self.class.where(email: value).present?
|
58
|
+
errors.add(:email, 'has already been taken')
|
59
|
+
raise("email has already been taken")
|
60
|
+
end
|
61
|
+
|
62
|
+
if respond_to?(:alternate_email) && self.class.where(alternate_email: value).present?
|
63
|
+
errors.add(:email, 'has already been taken')
|
57
64
|
raise("email has already been taken")
|
58
65
|
end
|
59
66
|
end
|
@@ -63,25 +70,29 @@ module EffectiveDeviseUser
|
|
63
70
|
assign_attributes(provider: nil, access_token: nil, refresh_token: nil, token_expires_at: nil)
|
64
71
|
end
|
65
72
|
|
73
|
+
validate(if: -> { email.present? && try(:alternate_email).present? }) do
|
74
|
+
errors.add(:alternate_email, 'cannot be the same as email') if email.strip.downcase == alternate_email.strip.downcase
|
75
|
+
end
|
76
|
+
|
66
77
|
# Uniqueness validation of emails and alternate emails across all users
|
67
78
|
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)
|
79
|
+
records = self.class.where.not(id: id)
|
71
80
|
|
72
|
-
#
|
73
|
-
if !
|
74
|
-
|
81
|
+
# Validate email uniqueness
|
82
|
+
if (value = email.to_s.strip.downcase).present? && !errors.added?(:email, 'has already been taken')
|
83
|
+
existing = records.where("email = :value OR alternate_email = :value", value: value)
|
84
|
+
errors.add(:email, 'has already been taken') if existing.present?
|
75
85
|
end
|
76
86
|
|
77
|
-
#
|
78
|
-
if
|
79
|
-
|
87
|
+
# Validate alternate_email uniqueness
|
88
|
+
if (value = alternate_email.to_s.strip.downcase).present?
|
89
|
+
existing = records.where("email = :value OR alternate_email = :value", value: value)
|
90
|
+
errors.add(:alternate_email, 'has already been taken') if existing.present?
|
80
91
|
end
|
81
92
|
end
|
82
93
|
|
83
94
|
with_options(if: -> { respond_to?(:alternate_email) }) do
|
84
|
-
validates :alternate_email, email: true
|
95
|
+
validates :alternate_email, email: true
|
85
96
|
end
|
86
97
|
|
87
98
|
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.6
|
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-10-
|
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
|