devise 3.5.2 → 3.5.3

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.

Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/CHANGELOG.md +17 -1
  4. data/CODE_OF_CONDUCT.md +22 -0
  5. data/CONTRIBUTING.md +2 -0
  6. data/Gemfile.lock +2 -2
  7. data/app/controllers/devise/passwords_controller.rb +1 -0
  8. data/app/mailers/devise/mailer.rb +4 -0
  9. data/app/views/devise/mailer/password_change.html.erb +3 -0
  10. data/app/views/devise/shared/_links.html.erb +1 -1
  11. data/config/locales/en.yml +2 -0
  12. data/gemfiles/Gemfile.rails-3.2-stable.lock +5 -2
  13. data/gemfiles/Gemfile.rails-4.0-stable.lock +5 -2
  14. data/gemfiles/Gemfile.rails-4.1-stable.lock +5 -2
  15. data/gemfiles/Gemfile.rails-4.2-stable.lock +5 -2
  16. data/lib/devise.rb +12 -3
  17. data/lib/devise/controllers/helpers.rb +12 -6
  18. data/lib/devise/failure_app.rb +17 -3
  19. data/lib/devise/hooks/timeoutable.rb +2 -1
  20. data/lib/devise/models.rb +1 -1
  21. data/lib/devise/models/confirmable.rb +2 -2
  22. data/lib/devise/models/database_authenticatable.rb +12 -2
  23. data/lib/devise/models/recoverable.rb +2 -6
  24. data/lib/devise/rails/routes.rb +17 -3
  25. data/lib/devise/strategies/authenticatable.rb +1 -1
  26. data/lib/devise/version.rb +1 -1
  27. data/lib/generators/devise/views_generator.rb +14 -3
  28. data/lib/generators/templates/devise.rb +3 -0
  29. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  30. data/lib/generators/templates/markerb/password_change.markerb +3 -0
  31. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  32. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  33. data/test/controllers/helper_methods_test.rb +21 -0
  34. data/test/failure_app_test.rb +17 -0
  35. data/test/generators/views_generator_test.rb +7 -0
  36. data/test/integration/omniauthable_test.rb +11 -9
  37. data/test/integration/timeoutable_test.rb +12 -0
  38. data/test/models/confirmable_test.rb +10 -0
  39. data/test/models/database_authenticatable_test.rb +20 -0
  40. data/test/models/lockable_test.rb +1 -1
  41. data/test/models/recoverable_test.rb +23 -0
  42. data/test/models_test.rb +15 -6
  43. data/test/rails_app/app/active_record/user_without_email.rb +8 -0
  44. data/test/rails_app/app/mongoid/user_without_email.rb +33 -0
  45. data/test/rails_app/config/routes.rb +5 -0
  46. data/test/rails_app/lib/shared_user_without_email.rb +26 -0
  47. data/test/support/helpers.rb +4 -0
  48. metadata +33 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b12e8ad372d99f51b3ad7363a604025e4b4351d3
4
- data.tar.gz: 2f532aa8b4538594a5dd1429a4613546dbd9f76a
3
+ metadata.gz: 1258976e4bec4149281c7764cf903ced83632766
4
+ data.tar.gz: 57096bdcca6de6c67b0fa26aee8251c446571c39
5
5
  SHA512:
6
- metadata.gz: c695e4e9960fb2acbc37047b3ec769d30d5a0adfd4925dc886ada51a386f7153ddaec12ea0181bb641f4aec815d7d356474fccf6dd8d19739593c880d5f5e544
7
- data.tar.gz: eae590deac848317c9db083a373efacd7f95f8ad84c93bee465d7fbe5a8a3c54b8f12f7a34d7cd602f215458bc9817247ff1eff8f6ad3d7bda6653a25a75f73e
6
+ metadata.gz: e3839e95f5c831805b43974ef72f7e6beca86d37c6c0177dec83ae5e8cc6ebcc5922da78cc505f413157ecdb0ed8b56c3c3499c061743a6ac25708e473ec035c
7
+ data.tar.gz: 59eb1f8398ddf1f4bd05a493a6ff4e41fb3f3580d0f3b143ffefed385b435fd3f521b1aaaaf0e8eee97838a1bc81d992081597738c743becfc4b651aa051b97f
@@ -38,8 +38,7 @@ script: "bundle exec rake test"
38
38
 
39
39
  notifications:
40
40
  email: false
41
- campfire:
41
+ slack:
42
42
  on_success: change
43
43
  on_failure: always
44
- rooms:
45
- - secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="
44
+ secure: Q3M+kmude3FjisibEeeGe0wSMXgvwLH+vL7Zrx9//q4QtkfnrQ/BBMvY9KXxPEsNF+eys4YopYjTkJ8uRmeboUATW/oQ4Jrv3+u3zkIHK2sFn/Q2cQWpK5w+CbgEnHPjKYnUu34b09njXTgDlr/mqtbPqrKeZ1dLlpKXCB/q4GY=
@@ -1,13 +1,29 @@
1
+ ### Unreleased
2
+
3
+ ### 3.5.3 - 2015-12-10
4
+
5
+ * bug fixes
6
+ * Fix password reset for records where `confirmation_required?` is disabled and
7
+ `confirmation_sent_at` is nil. (by @andygeers)
8
+ * Allow resources with no `email` field to be recoverable (and do not clear the
9
+ reset password token if the model was already persisted). (by @seddy, @stanhu)
10
+
11
+ * enhancements
12
+ * Upon setting `Devise.send_password_change_notification = true` a user will receive notification when their password has been changed.
13
+
1
14
  ### 3.5.2 - 2015-08-10
2
15
 
3
16
  * enhancements
4
17
  * Perform case insensitive basic authorization matching
5
18
 
6
- * Big fixes
19
+ * bug fixes
7
20
  * Do not use digests for password confirmation token
8
21
  * Fix infinite redirect in Rails 4.2 authenticated routes
9
22
  * Autoload Devise::Encryptor to avoid errors on thread-safe mode
10
23
 
24
+ * deprecations
25
+ * `config.expire_auth_token_on_timeout` was removed
26
+
11
27
  ### 3.5.1 - 2015-05-24
12
28
 
13
29
  Note: 3.5.0 has been yanked due to a regression
@@ -0,0 +1,22 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
6
+
7
+ Examples of unacceptable behavior by participants include:
8
+
9
+ * The use of sexualized language or imagery
10
+ * Personal attacks
11
+ * Trolling or insulting/derogatory comments
12
+ * Public or private harassment
13
+ * Publishing other's private information, such as physical or electronic addresses, without explicit permission
14
+ * Other unethical or unprofessional conduct.
15
+
16
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17
+
18
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
19
+
20
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [conduct@plataformatec.com.br](conduct@plataformatec.com.br) or contacting one or more of the project maintainers.
21
+
22
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
@@ -8,6 +8,8 @@
8
8
 
9
9
  4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
10
10
 
11
+ 5) Notice that all of your interactions in the project are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md)
12
+
11
13
  That's it! The more information you give, the easier it becomes for us to track it down and fix it.
12
14
  Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
13
15
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devise (3.5.2)
4
+ devise (3.5.3)
5
5
  bcrypt (~> 3.0)
6
6
  orm_adapter (~> 0.1)
7
7
  railties (>= 3.2.6, < 5)
@@ -153,7 +153,7 @@ GEM
153
153
  thread_safe (0.3.5)
154
154
  tzinfo (1.2.2)
155
155
  thread_safe (~> 0.1)
156
- warden (1.2.3)
156
+ warden (1.2.4)
157
157
  rack (>= 1.0)
158
158
  webrat (0.7.3)
159
159
  nokogiri (>= 1.2.0)
@@ -43,6 +43,7 @@ class Devise::PasswordsController < DeviseController
43
43
  end
44
44
  respond_with resource, location: after_resetting_password_path_for(resource)
45
45
  else
46
+ set_minimum_password_length
46
47
  respond_with resource
47
48
  end
48
49
  end
@@ -16,5 +16,9 @@ if defined?(ActionMailer)
16
16
  @token = token
17
17
  devise_mail(record, :unlock_instructions, opts)
18
18
  end
19
+
20
+ def password_change(record, opts={})
21
+ devise_mail(record, :password_change, opts)
22
+ end
19
23
  end
20
24
  end
@@ -0,0 +1,3 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>We're contacting you to notify you that your password has been changed.</p>
@@ -20,6 +20,6 @@
20
20
 
21
21
  <%- if devise_mapping.omniauthable? %>
22
22
  <%- resource_class.omniauth_providers.each do |provider| %>
23
- <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
23
+ <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br />
24
24
  <% end -%>
25
25
  <% end -%>
@@ -23,6 +23,8 @@ en:
23
23
  subject: "Reset password instructions"
24
24
  unlock_instructions:
25
25
  subject: "Unlock instructions"
26
+ password_change:
27
+ subject: "Password Changed"
26
28
  omniauth_callbacks:
27
29
  failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
30
  success: "Successfully authenticated from %{kind} account."
@@ -49,7 +49,7 @@ GIT
49
49
  PATH
50
50
  remote: ..
51
51
  specs:
52
- devise (3.4.1)
52
+ devise (3.5.3)
53
53
  bcrypt (~> 3.0)
54
54
  orm_adapter (~> 0.1)
55
55
  railties (>= 3.2.6, < 5)
@@ -142,7 +142,7 @@ GEM
142
142
  polyglot
143
143
  polyglot (>= 0.3.1)
144
144
  tzinfo (0.3.43)
145
- warden (1.2.3)
145
+ warden (1.2.4)
146
146
  rack (>= 1.0)
147
147
  webrat (0.7.3)
148
148
  nokogiri (>= 1.2.0)
@@ -167,3 +167,6 @@ DEPENDENCIES
167
167
  rdoc
168
168
  sqlite3
169
169
  webrat (= 0.7.3)
170
+
171
+ BUNDLED WITH
172
+ 1.10.6
@@ -43,7 +43,7 @@ GIT
43
43
  PATH
44
44
  remote: ..
45
45
  specs:
46
- devise (3.4.1)
46
+ devise (3.5.3)
47
47
  bcrypt (~> 3.0)
48
48
  orm_adapter (~> 0.1)
49
49
  railties (>= 3.2.6, < 5)
@@ -136,7 +136,7 @@ GEM
136
136
  thread_safe (0.3.5)
137
137
  tilt (1.4.1)
138
138
  tzinfo (0.3.43)
139
- warden (1.2.3)
139
+ warden (1.2.4)
140
140
  rack (>= 1.0)
141
141
  webrat (0.7.3)
142
142
  nokogiri (>= 1.2.0)
@@ -161,3 +161,6 @@ DEPENDENCIES
161
161
  rdoc
162
162
  sqlite3
163
163
  webrat (= 0.7.3)
164
+
165
+ BUNDLED WITH
166
+ 1.10.6
@@ -48,7 +48,7 @@ GIT
48
48
  PATH
49
49
  remote: ..
50
50
  specs:
51
- devise (3.4.1)
51
+ devise (3.5.3)
52
52
  bcrypt (~> 3.0)
53
53
  orm_adapter (~> 0.1)
54
54
  railties (>= 3.2.6, < 5)
@@ -142,7 +142,7 @@ GEM
142
142
  tilt (1.4.1)
143
143
  tzinfo (1.2.2)
144
144
  thread_safe (~> 0.1)
145
- warden (1.2.3)
145
+ warden (1.2.4)
146
146
  rack (>= 1.0)
147
147
  webrat (0.7.3)
148
148
  nokogiri (>= 1.2.0)
@@ -167,3 +167,6 @@ DEPENDENCIES
167
167
  rdoc
168
168
  sqlite3
169
169
  webrat (= 0.7.3)
170
+
171
+ BUNDLED WITH
172
+ 1.10.6
@@ -58,7 +58,7 @@ GIT
58
58
  PATH
59
59
  remote: ..
60
60
  specs:
61
- devise (3.4.1)
61
+ devise (3.5.3)
62
62
  bcrypt (~> 3.0)
63
63
  orm_adapter (~> 0.1)
64
64
  railties (>= 3.2.6, < 5)
@@ -164,7 +164,7 @@ GEM
164
164
  tilt (1.4.1)
165
165
  tzinfo (1.2.2)
166
166
  thread_safe (~> 0.1)
167
- warden (1.2.3)
167
+ warden (1.2.4)
168
168
  rack (>= 1.0)
169
169
  webrat (0.7.3)
170
170
  nokogiri (>= 1.2.0)
@@ -189,3 +189,6 @@ DEPENDENCIES
189
189
  rdoc
190
190
  sqlite3
191
191
  webrat (= 0.7.3)
192
+
193
+ BUNDLED WITH
194
+ 1.10.6
@@ -150,6 +150,10 @@ module Devise
150
150
  mattr_accessor :pepper
151
151
  @@pepper = nil
152
152
 
153
+ # Used to enable sending notification to user when their password is changed
154
+ mattr_accessor :send_password_change_notification
155
+ @@send_password_change_notification = false
156
+
153
157
  # Scoped views. Since it relies on fallbacks to render default views, it's
154
158
  # turned off by default.
155
159
  mattr_accessor :scoped_views
@@ -325,7 +329,12 @@ module Devise
325
329
  mapping
326
330
  end
327
331
 
328
- # Make Devise aware of an 3rd party Devise-module (like invitable). For convenience.
332
+ # Register available devise modules. For the standard modules that Devise provides, this method is
333
+ # called from lib/devise/modules.rb. Third-party modules need to be added explicitly using this method.
334
+ #
335
+ # Note that adding a module using this method does not cause it to be used in the authentication
336
+ # process. That requires that the module be listed in the arguments passed to the 'devise' method
337
+ # in the model class definition.
329
338
  #
330
339
  # == Options:
331
340
  #
@@ -433,8 +442,8 @@ module Devise
433
442
  Devise::Controllers::UrlHelpers.generate_helpers!
434
443
  end
435
444
 
436
- # A method used internally to setup warden manager from the Rails initialize
437
- # block.
445
+ # A method used internally to complete the setup of warden manager after routes are loaded.
446
+ # See lib/devise/rails/routes.rb - ActionDispatch::Routing::RouteSet#finalize_with_devise!
438
447
  def self.configure_warden! #:nodoc:
439
448
  @@warden_configured ||= begin
440
449
  warden_config.failure_app = Devise::Delegator.new
@@ -7,7 +7,9 @@ module Devise
7
7
  include Devise::Controllers::StoreLocation
8
8
 
9
9
  included do
10
- helper_method :warden, :signed_in?, :devise_controller?
10
+ if respond_to?(:helper_method)
11
+ helper_method :warden, :signed_in?, :devise_controller?
12
+ end
11
13
  end
12
14
 
13
15
  module ClassMethods
@@ -69,7 +71,9 @@ module Devise
69
71
  end.compact
70
72
  end
71
73
 
72
- helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
74
+ if respond_to?(:helper_method)
75
+ helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
76
+ end
73
77
  METHODS
74
78
  end
75
79
 
@@ -126,7 +130,9 @@ module Devise
126
130
  METHODS
127
131
 
128
132
  ActiveSupport.on_load(:action_controller) do
129
- helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
133
+ if respond_to?(:helper_method)
134
+ helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session"
135
+ end
130
136
  end
131
137
  end
132
138
 
@@ -190,10 +196,10 @@ module Devise
190
196
  # root path. For a user scope, you can define the default url in
191
197
  # the following way:
192
198
  #
193
- # map.user_root '/users', controller: 'users' # creates user_root_path
199
+ # get '/users' => 'users#index', as: :user_root # creates user_root_path
194
200
  #
195
- # map.namespace :user do |user|
196
- # user.root controller: 'users' # creates user_root_path
201
+ # namespace :user do
202
+ # root 'users#index' # creates user_root_path
197
203
  # end
198
204
  #
199
205
  # If the resource root path is not defined, root_path is used. However,
@@ -22,9 +22,12 @@ module Devise
22
22
  @respond.call(env)
23
23
  end
24
24
 
25
+ # Try retrieving the URL options from the parent controller (usually
26
+ # ApplicationController). Instance methods are not supported at the moment,
27
+ # so only the class-level attribute is used.
25
28
  def self.default_url_options(*args)
26
- if defined?(ApplicationController)
27
- ApplicationController.default_url_options(*args)
29
+ if defined?(Devise.parent_controller.constantize)
30
+ Devise.parent_controller.constantize.try(:default_url_options) || {}
28
31
  else
29
32
  {}
30
33
  end
@@ -48,7 +51,18 @@ module Devise
48
51
  end
49
52
 
50
53
  def recall
51
- env["PATH_INFO"] = attempted_path
54
+ config = Rails.application.config
55
+
56
+ if config.try(:relative_url_root)
57
+ base_path = Pathname.new(config.relative_url_root)
58
+ full_path = Pathname.new(attempted_path)
59
+
60
+ env["SCRIPT_NAME"] = config.relative_url_root
61
+ env["PATH_INFO"] = '/' + full_path.relative_path_from(base_path).to_s
62
+ else
63
+ env["PATH_INFO"] = attempted_path
64
+ end
65
+
52
66
  flash.now[:alert] = i18n_message(:invalid) if is_flashing_format?
53
67
  self.response = recall_app(warden_options[:recall]).call(env)
54
68
  end
@@ -7,7 +7,8 @@ Warden::Manager.after_set_user do |record, warden, options|
7
7
  scope = options[:scope]
8
8
  env = warden.request.env
9
9
 
10
- if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) && options[:store] != false
10
+ if record && record.respond_to?(:timedout?) && warden.authenticated?(scope) &&
11
+ options[:store] != false && !env['devise.skip_timeoutable']
11
12
  last_request_at = warden.session(scope)['last_request_at']
12
13
 
13
14
  if last_request_at.is_a? Integer
@@ -12,7 +12,7 @@ module Devise
12
12
 
13
13
  # Creates configuration values for Devise and for the given module.
14
14
  #
15
- # Devise::Models.config(Devise::Authenticatable, :stretches, 10)
15
+ # Devise::Models.config(Devise::DatabaseAuthenticatable, :stretches)
16
16
  #
17
17
  # The line above creates:
18
18
  #
@@ -24,7 +24,7 @@ module Devise
24
24
  # By default allow_unconfirmed_access_for is zero, it means users always have to confirm to sign in.
25
25
  # * +reconfirmable+: requires any email changes to be confirmed (exactly the same way as
26
26
  # initial account confirmation) to be applied. Requires additional unconfirmed_email
27
- # db field to be setup (t.reconfirmable in migrations). Until confirmed new email is
27
+ # db field to be setup (t.reconfirmable in migrations). Until confirmed, new email is
28
28
  # stored in unconfirmed email column, and copied to email column on successful
29
29
  # confirmation.
30
30
  # * +confirm_within+: the time before a sent confirmation token becomes invalid.
@@ -216,7 +216,7 @@ module Devise
216
216
  # confirmation_period_expired? # will always return false
217
217
  #
218
218
  def confirmation_period_expired?
219
- self.class.confirm_within && (Time.now > self.confirmation_sent_at + self.class.confirm_within)
219
+ self.class.confirm_within && self.confirmation_sent_at && (Time.now > self.confirmation_sent_at + self.class.confirm_within)
220
220
  end
221
221
 
222
222
  # Checks whether the record requires any confirmation.
@@ -12,7 +12,7 @@ module Devise
12
12
  #
13
13
  # == Options
14
14
  #
15
- # DatabaseAuthenticable adds the following options to devise_for:
15
+ # DatabaseAuthenticatable adds the following options to devise_for:
16
16
  #
17
17
  # * +pepper+: a random string used to provide a more secure hash. Use
18
18
  # `rake secret` to generate new keys.
@@ -27,6 +27,8 @@ module Devise
27
27
  extend ActiveSupport::Concern
28
28
 
29
29
  included do
30
+ after_update :send_password_change_notification, if: :send_password_change_notification?
31
+
30
32
  attr_reader :password, :current_password
31
33
  attr_accessor :password_confirmation
32
34
  end
@@ -133,6 +135,10 @@ module Devise
133
135
  encrypted_password[0,29] if encrypted_password
134
136
  end
135
137
 
138
+ def send_password_change_notification
139
+ send_devise_notification(:password_change)
140
+ end
141
+
136
142
  protected
137
143
 
138
144
  # Digests the password using bcrypt. Custom encryption should override
@@ -144,8 +150,12 @@ module Devise
144
150
  Devise::Encryptor.digest(self.class, password)
145
151
  end
146
152
 
153
+ def send_password_change_notification?
154
+ self.class.send_password_change_notification && encrypted_password_changed?
155
+ end
156
+
147
157
  module ClassMethods
148
- Devise::Models.config(self, :pepper, :stretches)
158
+ Devise::Models.config(self, :pepper, :stretches, :send_password_change_notification)
149
159
 
150
160
  # We assume this method already gets the sanitized values from the
151
161
  # DatabaseAuthenticatable strategy. If you are using this method on