effective_resources 2.10.0 → 2.11.0
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: 8000b25d219e4ce996d1c768682448fc912180f9d0b4808584182e94698255be
|
4
|
+
data.tar.gz: d1f99291b1a0072284c0432335541987b6e670b7e491d0e405befbcd42000282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e36bf1f67caf8510e570573621320ba328a311eebc60b8f764a0f811b5b49aedc713f615cb25ef5510786563e9b849a15efd1f4eef6dc86872bc4c26908af85
|
7
|
+
data.tar.gz: b6c593560fb53b762eee968c3d53dda47a208493155ef781089cddecc25771dbd18e748ca3336afdf29f187b2801c00ac07a2452457512c4c5788cba7777fb12
|
@@ -46,8 +46,10 @@ module Effective
|
|
46
46
|
helper EffectiveResourcesWizardHelper
|
47
47
|
|
48
48
|
rescue_from Wicked::Wizard::InvalidStepError do |exception|
|
49
|
-
|
50
|
-
|
49
|
+
step = resource.required_steps.first || resource_wizard_steps.first
|
50
|
+
|
51
|
+
flash[:danger] = "Unknown step. You have been moved to the #{step} step."
|
52
|
+
redirect_to wizard_path(step)
|
51
53
|
end
|
52
54
|
|
53
55
|
# effective_resources on save callback
|
@@ -172,7 +172,8 @@ module ActsAsWizard
|
|
172
172
|
existing = current_step
|
173
173
|
|
174
174
|
begin
|
175
|
-
self.current_step = nil
|
175
|
+
self.current_step = nil
|
176
|
+
yield
|
176
177
|
ensure
|
177
178
|
self.current_step = existing
|
178
179
|
end
|
@@ -191,7 +192,4 @@ module ActsAsWizard
|
|
191
192
|
end
|
192
193
|
|
193
194
|
end
|
194
|
-
|
195
|
-
|
196
|
-
|
197
195
|
end
|
@@ -46,7 +46,7 @@ module EffectiveDeviseUser
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Devise invitable ignores model validations, so we manually check for duplicate email addresses.
|
49
|
-
before_save(if: -> { new_record? && invitation_sent_at.present? }) do
|
49
|
+
before_save(if: -> { new_record? && try(:invitation_sent_at).present? }) do
|
50
50
|
if email.blank?
|
51
51
|
self.errors.add(:email, "can't be blank")
|
52
52
|
raise("email can't be blank")
|
@@ -62,6 +62,28 @@ module EffectiveDeviseUser
|
|
62
62
|
before_save(if: -> { persisted? && encrypted_password_changed? }) do
|
63
63
|
assign_attributes(provider: nil, access_token: nil, refresh_token: nil, token_expires_at: nil)
|
64
64
|
end
|
65
|
+
|
66
|
+
# Uniqueness validation of emails and alternate emails across all users
|
67
|
+
validate(if: -> { respond_to?(:alternate_email) }) do
|
68
|
+
records = self.class.where.not(id: self.id) # exclude self
|
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)
|
71
|
+
|
72
|
+
# Check if a uniqueness validation was already performed before triggering the exists query
|
73
|
+
if !self.errors.added?(:email, 'has already been taken') && email_duplicates.exists?
|
74
|
+
self.errors.add(:email, 'has already been taken')
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check if the alternate email is set before triggering the exists query
|
78
|
+
if try(:alternate_email).present? && alternate_email_duplicates.exists?
|
79
|
+
self.errors.add(:alternate_email, 'has already been taken')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
with_options(if: -> { respond_to?(:alternate_email) }) do
|
84
|
+
validates :alternate_email, email: true, allow_blank: true
|
85
|
+
end
|
86
|
+
|
65
87
|
end
|
66
88
|
|
67
89
|
module ClassMethods
|
@@ -162,10 +184,48 @@ module EffectiveDeviseUser
|
|
162
184
|
recoverable
|
163
185
|
end
|
164
186
|
|
187
|
+
# https://github.com/heartcombo/devise/blob/f6e73e5b5c8f519f4be29ac9069c6ed8a2343ce4/lib/devise/models/authenticatable.rb#L276
|
188
|
+
def find_first_by_auth_conditions(tainted_conditions, opts = {})
|
189
|
+
conditions = devise_parameter_filter.filter(tainted_conditions).merge(opts)
|
190
|
+
email = conditions[:email]
|
191
|
+
conditions.delete(:email)
|
192
|
+
|
193
|
+
user = to_adapter.find_first(conditions.merge(email: email))
|
194
|
+
return user if user.present? && user.persisted?
|
195
|
+
|
196
|
+
to_adapter.find_first(conditions.merge(alternate_email: email)) if respond_to?(:alternate_email)
|
197
|
+
end
|
198
|
+
|
199
|
+
# https://github.com/heartcombo/devise/blob/f6e73e5b5c8f519f4be29ac9069c6ed8a2343ce4/lib/devise/models/database_authenticatable.rb#L216
|
200
|
+
def find_for_database_authentication(warden_conditions)
|
201
|
+
conditions = warden_conditions.dup.presence || {}
|
202
|
+
primary_or_alternate_email = conditions[:email]
|
203
|
+
conditions.delete(:email)
|
204
|
+
|
205
|
+
has_alternate_email = 'alternate_email'.in? column_names
|
206
|
+
|
207
|
+
raise "Expected an email #{has_alternate_email ? 'or alternate email' : ''} but got [#{primary_or_alternate_email}] instead" if primary_or_alternate_email.blank?
|
208
|
+
|
209
|
+
query = if has_alternate_email
|
210
|
+
"lower(email) = :value OR lower(alternate_email) = :value"
|
211
|
+
else
|
212
|
+
"lower(email) = :value"
|
213
|
+
end
|
214
|
+
|
215
|
+
all
|
216
|
+
.where(conditions)
|
217
|
+
.where(query, value: primary_or_alternate_email.strip.downcase)
|
218
|
+
.first
|
219
|
+
end
|
220
|
+
|
165
221
|
end
|
166
222
|
|
167
223
|
# EffectiveDeviseUser Instance Methods
|
168
224
|
|
225
|
+
def alternate_email=(value)
|
226
|
+
super(value.to_s.strip.downcase.presence)
|
227
|
+
end
|
228
|
+
|
169
229
|
def reinvite!
|
170
230
|
invite!
|
171
231
|
end
|
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.
|
4
|
+
version: 2.11.0
|
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-09-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|