devise 3.5.1 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +53 -61
- data/README.md +4 -3
- data/app/controllers/devise/passwords_controller.rb +2 -3
- data/app/views/devise/passwords/edit.html.erb +2 -2
- data/devise.gemspec +0 -2
- data/lib/devise.rb +2 -5
- data/lib/devise/controllers/sign_in_out.rb +1 -7
- data/lib/devise/failure_app.rb +7 -2
- data/lib/devise/hooks/timeoutable.rb +0 -4
- data/lib/devise/models/confirmable.rb +20 -9
- data/lib/devise/models/database_authenticatable.rb +0 -1
- data/lib/devise/rails/routes.rb +8 -13
- data/lib/devise/strategies/authenticatable.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/templates/controllers/README +1 -1
- data/lib/generators/templates/devise.rb +0 -3
- data/test/devise_test.rb +1 -1
- data/test/integration/timeoutable_test.rb +0 -17
- data/test/mailers/confirmation_instructions_test.rb +1 -1
- data/test/models/confirmable_test.rb +13 -2
- data/test/rails_app/app/controllers/admins_controller.rb +0 -5
- data/test/rails_app/config/routes.rb +1 -3
- metadata +23 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b12e8ad372d99f51b3ad7363a604025e4b4351d3
|
4
|
+
data.tar.gz: 2f532aa8b4538594a5dd1429a4613546dbd9f76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c695e4e9960fb2acbc37047b3ec769d30d5a0adfd4925dc886ada51a386f7153ddaec12ea0181bb641f4aec815d7d356474fccf6dd8d19739593c880d5f5e544
|
7
|
+
data.tar.gz: eae590deac848317c9db083a373efacd7f95f8ad84c93bee465d7fbe5a8a3c54b8f12f7a34d7cd602f215458bc9817247ff1eff8f6ad3d7bda6653a25a75f73e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
### 3.5.2 - 2015-08-10
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Perform case insensitive basic authorization matching
|
5
|
+
|
6
|
+
* Big fixes
|
7
|
+
* Do not use digests for password confirmation token
|
8
|
+
* Fix infinite redirect in Rails 4.2 authenticated routes
|
9
|
+
* Autoload Devise::Encryptor to avoid errors on thread-safe mode
|
10
|
+
|
1
11
|
### 3.5.1 - 2015-05-24
|
2
12
|
|
3
13
|
Note: 3.5.0 has been yanked due to a regression
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem "rails", "4.2.
|
5
|
+
gem "rails", "4.2.2"
|
6
6
|
gem "omniauth", "~> 1.2.0"
|
7
7
|
gem "omniauth-oauth2", "~> 1.1.0"
|
8
8
|
gem "rdoc"
|
@@ -25,5 +25,5 @@ platforms :ruby do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
group :mongoid do
|
28
|
-
gem "mongoid",
|
28
|
+
gem "mongoid", "~> 4.0"
|
29
29
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devise (3.5.
|
4
|
+
devise (3.5.2)
|
5
5
|
bcrypt (~> 3.0)
|
6
6
|
orm_adapter (~> 0.1)
|
7
7
|
railties (>= 3.2.6, < 5)
|
@@ -9,50 +9,39 @@ PATH
|
|
9
9
|
thread_safe (~> 0.1)
|
10
10
|
warden (~> 1.2.3)
|
11
11
|
|
12
|
-
GIT
|
13
|
-
remote: git://github.com/mongoid/mongoid.git
|
14
|
-
revision: a4365d7ecfa8221bfcf36a4e7ce7993142fc5940
|
15
|
-
branch: master
|
16
|
-
specs:
|
17
|
-
mongoid (4.0.0)
|
18
|
-
activemodel (~> 4.0)
|
19
|
-
moped (~> 2.0.0)
|
20
|
-
origin (~> 2.1)
|
21
|
-
tzinfo (>= 0.3.37)
|
22
|
-
|
23
12
|
GEM
|
24
13
|
remote: https://rubygems.org/
|
25
14
|
specs:
|
26
|
-
actionmailer (4.2.
|
27
|
-
actionpack (= 4.2.
|
28
|
-
actionview (= 4.2.
|
29
|
-
activejob (= 4.2.
|
15
|
+
actionmailer (4.2.2)
|
16
|
+
actionpack (= 4.2.2)
|
17
|
+
actionview (= 4.2.2)
|
18
|
+
activejob (= 4.2.2)
|
30
19
|
mail (~> 2.5, >= 2.5.4)
|
31
20
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
32
|
-
actionpack (4.2.
|
33
|
-
actionview (= 4.2.
|
34
|
-
activesupport (= 4.2.
|
21
|
+
actionpack (4.2.2)
|
22
|
+
actionview (= 4.2.2)
|
23
|
+
activesupport (= 4.2.2)
|
35
24
|
rack (~> 1.6)
|
36
25
|
rack-test (~> 0.6.2)
|
37
26
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
38
27
|
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
39
|
-
actionview (4.2.
|
40
|
-
activesupport (= 4.2.
|
28
|
+
actionview (4.2.2)
|
29
|
+
activesupport (= 4.2.2)
|
41
30
|
builder (~> 3.1)
|
42
31
|
erubis (~> 2.7.0)
|
43
32
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
44
33
|
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
45
|
-
activejob (4.2.
|
46
|
-
activesupport (= 4.2.
|
34
|
+
activejob (4.2.2)
|
35
|
+
activesupport (= 4.2.2)
|
47
36
|
globalid (>= 0.3.0)
|
48
|
-
activemodel (4.2.
|
49
|
-
activesupport (= 4.2.
|
37
|
+
activemodel (4.2.2)
|
38
|
+
activesupport (= 4.2.2)
|
50
39
|
builder (~> 3.1)
|
51
|
-
activerecord (4.2.
|
52
|
-
activemodel (= 4.2.
|
53
|
-
activesupport (= 4.2.
|
40
|
+
activerecord (4.2.2)
|
41
|
+
activemodel (= 4.2.2)
|
42
|
+
activesupport (= 4.2.2)
|
54
43
|
arel (~> 6.0)
|
55
|
-
activesupport (4.2.
|
44
|
+
activesupport (4.2.2)
|
56
45
|
i18n (~> 0.7)
|
57
46
|
json (~> 1.7, >= 1.7.7)
|
58
47
|
minitest (~> 5.1)
|
@@ -60,34 +49,38 @@ GEM
|
|
60
49
|
tzinfo (~> 1.1)
|
61
50
|
arel (6.0.0)
|
62
51
|
bcrypt (3.1.10)
|
63
|
-
bson (
|
52
|
+
bson (3.1.2)
|
64
53
|
builder (3.2.2)
|
65
|
-
connection_pool (2.
|
54
|
+
connection_pool (2.2.0)
|
66
55
|
erubis (2.7.0)
|
67
56
|
faraday (0.9.1)
|
68
57
|
multipart-post (>= 1.2, < 3)
|
69
|
-
globalid (0.3.
|
58
|
+
globalid (0.3.5)
|
70
59
|
activesupport (>= 4.1.0)
|
71
60
|
hashie (3.4.0)
|
72
|
-
hike (1.2.3)
|
73
61
|
i18n (0.7.0)
|
74
|
-
json (1.8.
|
62
|
+
json (1.8.3)
|
75
63
|
jwt (1.4.1)
|
76
|
-
loofah (2.0.
|
64
|
+
loofah (2.0.2)
|
77
65
|
nokogiri (>= 1.5.9)
|
78
66
|
mail (2.6.3)
|
79
67
|
mime-types (>= 1.16, < 3)
|
80
68
|
metaclass (0.0.4)
|
81
|
-
mime-types (2.
|
69
|
+
mime-types (2.6.1)
|
82
70
|
mini_portile (0.6.2)
|
83
|
-
minitest (5.
|
71
|
+
minitest (5.7.0)
|
84
72
|
mocha (1.1.0)
|
85
73
|
metaclass (~> 0.0.1)
|
86
|
-
|
87
|
-
|
74
|
+
mongoid (4.0.2)
|
75
|
+
activemodel (~> 4.0)
|
76
|
+
moped (~> 2.0.0)
|
77
|
+
origin (~> 2.1)
|
78
|
+
tzinfo (>= 0.3.37)
|
79
|
+
moped (2.0.6)
|
80
|
+
bson (~> 3.0)
|
88
81
|
connection_pool (~> 2.0)
|
89
82
|
optionable (~> 0.2.0)
|
90
|
-
multi_json (1.11.
|
83
|
+
multi_json (1.11.1)
|
91
84
|
multi_xml (0.5.5)
|
92
85
|
multipart-post (2.0.0)
|
93
86
|
nokogiri (1.6.6.2)
|
@@ -114,22 +107,22 @@ GEM
|
|
114
107
|
optionable (0.2.0)
|
115
108
|
origin (2.1.1)
|
116
109
|
orm_adapter (0.5.0)
|
117
|
-
rack (1.6.
|
110
|
+
rack (1.6.2)
|
118
111
|
rack-openid (1.3.1)
|
119
112
|
rack (>= 1.1.0)
|
120
113
|
ruby-openid (>= 2.1.8)
|
121
114
|
rack-test (0.6.3)
|
122
115
|
rack (>= 1.0)
|
123
|
-
rails (4.2.
|
124
|
-
actionmailer (= 4.2.
|
125
|
-
actionpack (= 4.2.
|
126
|
-
actionview (= 4.2.
|
127
|
-
activejob (= 4.2.
|
128
|
-
activemodel (= 4.2.
|
129
|
-
activerecord (= 4.2.
|
130
|
-
activesupport (= 4.2.
|
116
|
+
rails (4.2.2)
|
117
|
+
actionmailer (= 4.2.2)
|
118
|
+
actionpack (= 4.2.2)
|
119
|
+
actionview (= 4.2.2)
|
120
|
+
activejob (= 4.2.2)
|
121
|
+
activemodel (= 4.2.2)
|
122
|
+
activerecord (= 4.2.2)
|
123
|
+
activesupport (= 4.2.2)
|
131
124
|
bundler (>= 1.3.0, < 2.0)
|
132
|
-
railties (= 4.2.
|
125
|
+
railties (= 4.2.2)
|
133
126
|
sprockets-rails
|
134
127
|
rails-deprecated_sanitizer (1.0.3)
|
135
128
|
activesupport (>= 4.2.0.alpha)
|
@@ -139,9 +132,9 @@ GEM
|
|
139
132
|
rails-deprecated_sanitizer (>= 1.0.1)
|
140
133
|
rails-html-sanitizer (1.0.2)
|
141
134
|
loofah (~> 2.0)
|
142
|
-
railties (4.2.
|
143
|
-
actionpack (= 4.2.
|
144
|
-
activesupport (= 4.2.
|
135
|
+
railties (4.2.2)
|
136
|
+
actionpack (= 4.2.2)
|
137
|
+
activesupport (= 4.2.2)
|
145
138
|
rake (>= 0.8.7)
|
146
139
|
thor (>= 0.18.1, < 2.0)
|
147
140
|
rake (10.4.2)
|
@@ -149,19 +142,15 @@ GEM
|
|
149
142
|
responders (2.1.0)
|
150
143
|
railties (>= 4.2.0, < 5)
|
151
144
|
ruby-openid (2.7.0)
|
152
|
-
sprockets (2.
|
153
|
-
hike (~> 1.2)
|
154
|
-
multi_json (~> 1.0)
|
145
|
+
sprockets (3.2.0)
|
155
146
|
rack (~> 1.0)
|
156
|
-
|
157
|
-
sprockets-rails (2.2.4)
|
147
|
+
sprockets-rails (2.3.1)
|
158
148
|
actionpack (>= 3.0)
|
159
149
|
activesupport (>= 3.0)
|
160
150
|
sprockets (>= 2.8, < 4.0)
|
161
151
|
sqlite3 (1.3.10)
|
162
152
|
thor (0.19.1)
|
163
153
|
thread_safe (0.3.5)
|
164
|
-
tilt (1.4.1)
|
165
154
|
tzinfo (1.2.2)
|
166
155
|
thread_safe (~> 0.1)
|
167
156
|
warden (1.2.3)
|
@@ -180,12 +169,15 @@ DEPENDENCIES
|
|
180
169
|
devise!
|
181
170
|
jruby-openssl
|
182
171
|
mocha (~> 1.1)
|
183
|
-
mongoid
|
172
|
+
mongoid (~> 4.0)
|
184
173
|
omniauth (~> 1.2.0)
|
185
174
|
omniauth-facebook
|
186
175
|
omniauth-oauth2 (~> 1.1.0)
|
187
176
|
omniauth-openid (~> 1.0.1)
|
188
|
-
rails (= 4.2.
|
177
|
+
rails (= 4.2.2)
|
189
178
|
rdoc
|
190
179
|
sqlite3
|
191
180
|
webrat (= 0.7.3)
|
181
|
+
|
182
|
+
BUNDLED WITH
|
183
|
+
1.10.6
|
data/README.md
CHANGED
@@ -82,10 +82,11 @@ You will usually want to write tests for your changes. To run the test suite, g
|
|
82
82
|
|
83
83
|
## Starting with Rails?
|
84
84
|
|
85
|
-
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today we have
|
85
|
+
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today, we have three resources that should help you get started:
|
86
86
|
|
87
87
|
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
88
88
|
* Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
|
89
|
+
* Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
|
89
90
|
|
90
91
|
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
|
91
92
|
|
@@ -185,7 +186,7 @@ Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`,
|
|
185
186
|
|
186
187
|
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
|
187
188
|
|
188
|
-
There are just three actions in Devise that
|
189
|
+
There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
|
189
190
|
|
190
191
|
* `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
|
191
192
|
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
@@ -348,7 +349,7 @@ devise_for :users, path: "auth", path_names: { sign_in: 'login', sign_out: 'logo
|
|
348
349
|
|
349
350
|
Be sure to check `devise_for` documentation for details.
|
350
351
|
|
351
|
-
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is
|
352
|
+
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
|
352
353
|
|
353
354
|
```ruby
|
354
355
|
devise_scope :user do
|
@@ -38,11 +38,10 @@ class Devise::PasswordsController < DeviseController
|
|
38
38
|
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
|
39
39
|
set_flash_message(:notice, flash_message) if is_flashing_format?
|
40
40
|
sign_in(resource_name, resource)
|
41
|
-
respond_with resource, location: after_resetting_password_path_for(resource)
|
42
41
|
else
|
43
42
|
set_flash_message(:notice, :updated_not_active) if is_flashing_format?
|
44
|
-
respond_with resource, location: new_session_path(resource_name)
|
45
43
|
end
|
44
|
+
respond_with resource, location: after_resetting_password_path_for(resource)
|
46
45
|
else
|
47
46
|
respond_with resource
|
48
47
|
end
|
@@ -50,7 +49,7 @@ class Devise::PasswordsController < DeviseController
|
|
50
49
|
|
51
50
|
protected
|
52
51
|
def after_resetting_password_path_for(resource)
|
53
|
-
after_sign_in_path_for(resource)
|
52
|
+
Devise.sign_in_after_reset_password ? after_sign_in_path_for(resource) : new_session_path(resource_name)
|
54
53
|
end
|
55
54
|
|
56
55
|
# The path used after sending reset password instructions
|
@@ -7,8 +7,8 @@
|
|
7
7
|
<div class="field">
|
8
8
|
<%= f.label :password, "New password" %><br />
|
9
9
|
<% if @minimum_password_length %>
|
10
|
-
|
11
|
-
<% end
|
10
|
+
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
|
11
|
+
<% end %>
|
12
12
|
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
13
13
|
</div>
|
14
14
|
|
data/devise.gemspec
CHANGED
@@ -13,8 +13,6 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.description = "Flexible authentication solution for Rails with Warden"
|
14
14
|
s.authors = ['José Valim', 'Carlos Antônio']
|
15
15
|
|
16
|
-
s.rubyforge_project = "devise"
|
17
|
-
|
18
16
|
s.files = `git ls-files`.split("\n")
|
19
17
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
18
|
s.require_paths = ["lib"]
|
data/lib/devise.rb
CHANGED
@@ -8,6 +8,7 @@ require 'responders'
|
|
8
8
|
|
9
9
|
module Devise
|
10
10
|
autoload :Delegator, 'devise/delegator'
|
11
|
+
autoload :Encryptor, 'devise/encryptor'
|
11
12
|
autoload :FailureApp, 'devise/failure_app'
|
12
13
|
autoload :OmniAuth, 'devise/omniauth'
|
13
14
|
autoload :ParameterFilter, 'devise/parameter_filter'
|
@@ -105,7 +106,7 @@ module Devise
|
|
105
106
|
# an one (and only one) @ exists in the given string. This is mainly
|
106
107
|
# to give user feedback and not to assert the e-mail validity.
|
107
108
|
mattr_accessor :email_regexp
|
108
|
-
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\
|
109
|
+
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
|
109
110
|
|
110
111
|
# Range validation for password length
|
111
112
|
mattr_accessor :password_length
|
@@ -145,10 +146,6 @@ module Devise
|
|
145
146
|
mattr_accessor :timeout_in
|
146
147
|
@@timeout_in = 30.minutes
|
147
148
|
|
148
|
-
# Authentication token expiration on timeout
|
149
|
-
mattr_accessor :expire_auth_token_on_timeout
|
150
|
-
@@expire_auth_token_on_timeout = false
|
151
|
-
|
152
149
|
# Used to encrypt password. Please generate one with rake secret.
|
153
150
|
mattr_accessor :pepper
|
154
151
|
@@pepper = nil
|
@@ -90,13 +90,7 @@ module Devise
|
|
90
90
|
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
# session.keys will return an empty array if the session is not yet loaded.
|
95
|
-
# This is a bug in both Rack and Rails.
|
96
|
-
# A call to #empty? forces the session to be loaded.
|
97
|
-
session.empty?
|
98
|
-
session.keys.grep(/^devise\./).each { |k| session.delete(k) }
|
99
|
-
end
|
93
|
+
alias :expire_data_after_sign_out! :expire_data_after_sign_in!
|
100
94
|
end
|
101
95
|
end
|
102
96
|
end
|
data/lib/devise/failure_app.rb
CHANGED
@@ -118,8 +118,13 @@ module Devise
|
|
118
118
|
|
119
119
|
config = Rails.application.config
|
120
120
|
|
121
|
-
if
|
122
|
-
|
121
|
+
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
|
122
|
+
if (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
|
123
|
+
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
|
124
|
+
else
|
125
|
+
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
|
126
|
+
opts[:script_name] = config.relative_url_root
|
127
|
+
end
|
123
128
|
end
|
124
129
|
|
125
130
|
router_name = Devise.mappings[scope].router_name || Devise.available_router_name
|
@@ -21,10 +21,6 @@ Warden::Manager.after_set_user do |record, warden, options|
|
|
21
21
|
if record.timedout?(last_request_at) && !env['devise.skip_timeout']
|
22
22
|
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
|
23
23
|
|
24
|
-
if record.respond_to?(:expire_auth_token_on_timeout) && record.expire_auth_token_on_timeout
|
25
|
-
record.reset_authentication_token!
|
26
|
-
end
|
27
|
-
|
28
24
|
throw :warden, scope: scope, message: :timeout
|
29
25
|
end
|
30
26
|
|
@@ -7,7 +7,7 @@ module Devise
|
|
7
7
|
#
|
8
8
|
# Confirmable tracks the following columns:
|
9
9
|
#
|
10
|
-
# * confirmation_token -
|
10
|
+
# * confirmation_token - A unique random token
|
11
11
|
# * confirmed_at - A timestamp when the user clicked the confirmation link
|
12
12
|
# * confirmation_sent_at - A timestamp when the confirmation_token was generated (not sent)
|
13
13
|
# * unconfirmed_email - An email address copied from the email attr. After confirmation
|
@@ -29,6 +29,8 @@ module Devise
|
|
29
29
|
# confirmation.
|
30
30
|
# * +confirm_within+: the time before a sent confirmation token becomes invalid.
|
31
31
|
# You can use this to force the user to confirm within a set period of time.
|
32
|
+
# Confirmable will not generate a new token if a repeat confirmation is requested
|
33
|
+
# during this time frame, unless the user's email changed too.
|
32
34
|
#
|
33
35
|
# == Examples
|
34
36
|
#
|
@@ -230,10 +232,13 @@ module Devise
|
|
230
232
|
# Generates a new random token for confirmation, and stores
|
231
233
|
# the time this token is being generated in confirmation_sent_at
|
232
234
|
def generate_confirmation_token
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
235
|
+
if self.confirmation_token && !confirmation_period_expired?
|
236
|
+
@raw_confirmation_token = self.confirmation_token
|
237
|
+
else
|
238
|
+
raw, _ = Devise.token_generator.generate(self.class, :confirmation_token)
|
239
|
+
self.confirmation_token = @raw_confirmation_token = raw
|
240
|
+
self.confirmation_sent_at = Time.now.utc
|
241
|
+
end
|
237
242
|
end
|
238
243
|
|
239
244
|
def generate_confirmation_token!
|
@@ -244,6 +249,7 @@ module Devise
|
|
244
249
|
@reconfirmation_required = true
|
245
250
|
self.unconfirmed_email = self.email
|
246
251
|
self.email = self.email_was
|
252
|
+
self.confirmation_token = nil
|
247
253
|
generate_confirmation_token
|
248
254
|
end
|
249
255
|
|
@@ -293,12 +299,17 @@ module Devise
|
|
293
299
|
# If the user is already confirmed, create an error for the user
|
294
300
|
# Options must have the confirmation_token
|
295
301
|
def confirm_by_token(confirmation_token)
|
296
|
-
|
297
|
-
|
302
|
+
confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token)
|
303
|
+
unless confirmable
|
304
|
+
confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token)
|
305
|
+
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest)
|
306
|
+
end
|
307
|
+
|
308
|
+
# TODO: replace above lines with
|
309
|
+
# confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
310
|
+
# after enough time has passed that Devise clients do not use digested tokens
|
298
311
|
|
299
|
-
confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token)
|
300
312
|
confirmable.confirm if confirmable.persisted?
|
301
|
-
confirmable.confirmation_token = original_token
|
302
313
|
confirmable
|
303
314
|
end
|
304
315
|
|
data/lib/devise/rails/routes.rb
CHANGED
@@ -404,19 +404,14 @@ module ActionDispatch::Routing
|
|
404
404
|
raise <<-ERROR
|
405
405
|
Devise does not support scoping OmniAuth callbacks under a dynamic segment
|
406
406
|
and you have set #{mapping.fullpath.inspect}. You can work around by passing
|
407
|
-
`skip: :omniauth_callbacks`
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
match "/users/auth/:action/callback",
|
416
|
-
constraints: { action: /google|facebook/ },
|
417
|
-
to: "devise/omniauth_callbacks#:action",
|
418
|
-
as: :omniauth_callback,
|
419
|
-
via: [:get, :post]
|
407
|
+
`skip: :omniauth_callbacks` to the `devise_for` call and extract omniauth
|
408
|
+
options to another `devise_for` call outside the scope. Here is an example:
|
409
|
+
|
410
|
+
devise_for :users, only: :omniauth_callbacks, controllers: {omniauth_callbacks: 'users/omniauth_callbacks'}
|
411
|
+
|
412
|
+
scope '/(:locale)', locale: /ru|en/ do
|
413
|
+
devise_for :users, skip: :omniauth_callbacks
|
414
|
+
end
|
420
415
|
ERROR
|
421
416
|
end
|
422
417
|
|
@@ -118,7 +118,7 @@ module Devise
|
|
118
118
|
|
119
119
|
# Helper to decode credentials from HTTP.
|
120
120
|
def decode_credentials
|
121
|
-
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/
|
121
|
+
return [] unless request.authorization && request.authorization =~ /^Basic (.*)/mi
|
122
122
|
Base64.decode64($1).split(/:/, 2)
|
123
123
|
end
|
124
124
|
|
data/lib/devise/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Some setup you must do manually if you haven't yet:
|
4
4
|
|
5
|
-
Ensure you have overridden routes for generated controllers in your
|
5
|
+
Ensure you have overridden routes for generated controllers in your routes.rb.
|
6
6
|
For example:
|
7
7
|
|
8
8
|
Rails.application.routes.draw do
|
@@ -158,9 +158,6 @@ Devise.setup do |config|
|
|
158
158
|
# time the user will be asked for credentials again. Default is 30 minutes.
|
159
159
|
# config.timeout_in = 30.minutes
|
160
160
|
|
161
|
-
# If true, expires auth token on session timeout.
|
162
|
-
# config.expire_auth_token_on_timeout = false
|
163
|
-
|
164
161
|
# ==> Configuration for :lockable
|
165
162
|
# Defines which strategy will be used to lock an account.
|
166
163
|
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
data/test/devise_test.rb
CHANGED
@@ -95,7 +95,7 @@ class DeviseTest < ActiveSupport::TestCase
|
|
95
95
|
|
96
96
|
test 'Devise.email_regexp should match valid email addresses' do
|
97
97
|
valid_emails = ["test@example.com", "jo@jo.co", "f4$_m@you.com", "testing.example@example.com.ua"]
|
98
|
-
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com"]
|
98
|
+
non_valid_emails = ["rex", "test@go,com", "test user@example.com", "test_user@example server.com", "test_user@example.com."]
|
99
99
|
|
100
100
|
valid_emails.each do |email|
|
101
101
|
assert_match Devise.email_regexp, email
|
@@ -110,23 +110,6 @@ class SessionTimeoutTest < ActionDispatch::IntegrationTest
|
|
110
110
|
assert_contain 'You are signed in'
|
111
111
|
end
|
112
112
|
|
113
|
-
test 'admin does not explode on time out' do
|
114
|
-
admin = sign_in_as_admin
|
115
|
-
get expire_admin_path(admin)
|
116
|
-
|
117
|
-
Admin.send :define_method, :reset_authentication_token! do
|
118
|
-
nil
|
119
|
-
end
|
120
|
-
|
121
|
-
begin
|
122
|
-
get admins_path
|
123
|
-
assert_redirected_to admins_path
|
124
|
-
assert_not warden.authenticated?(:admin)
|
125
|
-
ensure
|
126
|
-
Admin.send(:remove_method, :reset_authentication_token!)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
113
|
test 'user configured timeout limit' do
|
131
114
|
swap Devise, timeout_in: 8.minutes do
|
132
115
|
user = sign_in_as_user
|
@@ -86,7 +86,7 @@ class ConfirmationInstructionsTest < ActionMailer::TestCase
|
|
86
86
|
host, port = ActionMailer::Base.default_url_options.values_at :host, :port
|
87
87
|
|
88
88
|
if mail.body.encoded =~ %r{<a href=\"http://#{host}:#{port}/users/confirmation\?confirmation_token=([^"]+)">}
|
89
|
-
assert_equal
|
89
|
+
assert_equal $1, user.confirmation_token
|
90
90
|
else
|
91
91
|
flunk "expected confirmation url regex to match"
|
92
92
|
end
|
@@ -291,12 +291,23 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
291
291
|
end
|
292
292
|
end
|
293
293
|
|
294
|
-
test '
|
294
|
+
test 'do not generate a new token on resend' do
|
295
295
|
user = create_user
|
296
296
|
old = user.confirmation_token
|
297
297
|
user = User.find(user.id)
|
298
298
|
user.resend_confirmation_instructions
|
299
|
-
|
299
|
+
assert_equal user.confirmation_token, old
|
300
|
+
end
|
301
|
+
|
302
|
+
test 'generate a new token after first has expired' do
|
303
|
+
swap Devise, confirm_within: 3.days do
|
304
|
+
user = create_user
|
305
|
+
old = user.confirmation_token
|
306
|
+
user.update_attribute(:confirmation_sent_at, 4.days.ago)
|
307
|
+
user = User.find(user.id)
|
308
|
+
user.resend_confirmation_instructions
|
309
|
+
assert_not_equal user.confirmation_token, old
|
310
|
+
end
|
300
311
|
end
|
301
312
|
|
302
313
|
test 'should call after_confirmation if confirmed' do
|
@@ -13,9 +13,7 @@ Rails.application.routes.draw do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
resources :admins, only: [:index]
|
17
|
-
get :expire, on: :member
|
18
|
-
end
|
16
|
+
resources :admins, only: [:index]
|
19
17
|
|
20
18
|
# Users scope
|
21
19
|
devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -9,96 +9,96 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: warden
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 1.2.3
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 1.2.3
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: orm_adapter
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0.1'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0.1'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: bcrypt
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '3.0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '3.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: thread_safe
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0.1'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0.1'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: railties
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 3.2.6
|
77
|
-
- -
|
77
|
+
- - <
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '5'
|
80
80
|
type: :runtime
|
81
81
|
prerelease: false
|
82
82
|
version_requirements: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- -
|
84
|
+
- - '>='
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 3.2.6
|
87
|
-
- -
|
87
|
+
- - <
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '5'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: responders
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
description: Flexible authentication solution for Rails with Warden
|
@@ -107,9 +107,9 @@ executables: []
|
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
110
|
+
- .gitignore
|
111
|
+
- .travis.yml
|
112
|
+
- .yardopts
|
113
113
|
- CHANGELOG.md
|
114
114
|
- CONTRIBUTING.md
|
115
115
|
- Gemfile
|
@@ -366,17 +366,17 @@ require_paths:
|
|
366
366
|
- lib
|
367
367
|
required_ruby_version: !ruby/object:Gem::Requirement
|
368
368
|
requirements:
|
369
|
-
- -
|
369
|
+
- - '>='
|
370
370
|
- !ruby/object:Gem::Version
|
371
371
|
version: 1.9.3
|
372
372
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
|
-
- -
|
374
|
+
- - '>='
|
375
375
|
- !ruby/object:Gem::Version
|
376
376
|
version: '0'
|
377
377
|
requirements: []
|
378
|
-
rubyforge_project:
|
379
|
-
rubygems_version: 2.
|
378
|
+
rubyforge_project:
|
379
|
+
rubygems_version: 2.0.3
|
380
380
|
signing_key:
|
381
381
|
specification_version: 4
|
382
382
|
summary: Flexible authentication solution for Rails with Warden
|