loyal_devise 2.2.5 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/devise/models/confirmable.rb +13 -13
- data/lib/devise/version.rb +1 -1
- metadata +4 -4
@@ -24,8 +24,8 @@ module Devise
|
|
24
24
|
#
|
25
25
|
# == Examples
|
26
26
|
#
|
27
|
-
# User.find(1).
|
28
|
-
# User.find(1).
|
27
|
+
# User.find(1).email_confirm! # returns true unless it's already confirmed
|
28
|
+
# User.find(1).email_confirmed? # true/false
|
29
29
|
# User.find(1).send_confirmation_instructions # manually send instructions
|
30
30
|
#
|
31
31
|
module Confirmable
|
@@ -33,7 +33,7 @@ module Devise
|
|
33
33
|
include ActionView::Helpers::DateHelper
|
34
34
|
|
35
35
|
included do
|
36
|
-
before_create :generate_confirmation_token, :if => :
|
36
|
+
before_create :generate_confirmation_token, :if => :email_confirmation_required?
|
37
37
|
after_create :send_on_create_confirmation_instructions, :if => :send_confirmation_notification?
|
38
38
|
before_update :postpone_email_change_until_confirmation, :if => :postpone_email_change?
|
39
39
|
after_update :send_confirmation_instructions, :if => :reconfirmation_required?
|
@@ -55,7 +55,7 @@ module Devise
|
|
55
55
|
# Confirm a user by setting it's confirmed_at to actual time. If the user
|
56
56
|
# is already confirmed, add an error to email field. If the user is invalid
|
57
57
|
# add errors
|
58
|
-
def
|
58
|
+
def email_confirm!
|
59
59
|
pending_any_confirmation do
|
60
60
|
if confirmation_period_expired?
|
61
61
|
self.errors.add(:email, :confirmation_period_expired,
|
@@ -80,7 +80,7 @@ module Devise
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Verifies whether a user is confirmed or not
|
83
|
-
def
|
83
|
+
def email_confirmed?
|
84
84
|
!!confirmed_at
|
85
85
|
end
|
86
86
|
|
@@ -112,12 +112,12 @@ module Devise
|
|
112
112
|
# is already confirmed, it should never be blocked. Otherwise we need to
|
113
113
|
# calculate if the confirm time has not expired for this user.
|
114
114
|
def active_for_authentication?
|
115
|
-
super && (!
|
115
|
+
super && (!email_confirmation_required? || email_confirmed? || confirmation_period_valid?)
|
116
116
|
end
|
117
117
|
|
118
118
|
# The message to be shown if the account is inactive.
|
119
119
|
def inactive_message
|
120
|
-
!
|
120
|
+
!email_confirmed? ? :unconfirmed : super
|
121
121
|
end
|
122
122
|
|
123
123
|
# If you don't want confirmation to be sent on create, neither a code
|
@@ -148,8 +148,8 @@ module Devise
|
|
148
148
|
end
|
149
149
|
|
150
150
|
# Callback to overwrite if confirmation is required or not.
|
151
|
-
def
|
152
|
-
!
|
151
|
+
def email_confirmation_required?
|
152
|
+
!email_confirmed?
|
153
153
|
end
|
154
154
|
|
155
155
|
# Checks if the confirmation for the user is within the limit time.
|
@@ -196,7 +196,7 @@ module Devise
|
|
196
196
|
|
197
197
|
# Checks whether the record requires any confirmation.
|
198
198
|
def pending_any_confirmation
|
199
|
-
if (!
|
199
|
+
if (!email_confirmed? || pending_reconfirmation?)
|
200
200
|
yield
|
201
201
|
else
|
202
202
|
self.errors.add(:email, :already_confirmed)
|
@@ -217,7 +217,7 @@ module Devise
|
|
217
217
|
|
218
218
|
def after_password_reset
|
219
219
|
super
|
220
|
-
|
220
|
+
email_confirm! unless email_confirmed?
|
221
221
|
end
|
222
222
|
|
223
223
|
def postpone_email_change_until_confirmation
|
@@ -237,7 +237,7 @@ module Devise
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def send_confirmation_notification?
|
240
|
-
|
240
|
+
email_confirmation_required? && !@skip_confirmation_notification
|
241
241
|
end
|
242
242
|
|
243
243
|
module ClassMethods
|
@@ -260,7 +260,7 @@ module Devise
|
|
260
260
|
# Options must have the confirmation_token
|
261
261
|
def confirm_by_token(confirmation_token)
|
262
262
|
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
263
|
-
confirmable.
|
263
|
+
confirmable.email_confirm! if confirmable.persisted?
|
264
264
|
confirmable
|
265
265
|
end
|
266
266
|
|
data/lib/devise/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loyal_devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: loyal_warden
|
@@ -212,7 +212,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
segments:
|
214
214
|
- 0
|
215
|
-
hash:
|
215
|
+
hash: 126468515477557902
|
216
216
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
217
|
none: false
|
218
218
|
requirements:
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
segments:
|
223
223
|
- 0
|
224
|
-
hash:
|
224
|
+
hash: 126468515477557902
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project: loyal_devise
|
227
227
|
rubygems_version: 1.8.25
|