devise 3.2.3 → 3.2.4

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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile +2 -2
  4. data/Gemfile.lock +6 -6
  5. data/README.md +7 -0
  6. data/Rakefile +1 -1
  7. data/app/controllers/devise/confirmations_controller.rb +2 -2
  8. data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
  9. data/app/controllers/devise/passwords_controller.rb +3 -3
  10. data/app/controllers/devise/registrations_controller.rb +7 -7
  11. data/app/controllers/devise/sessions_controller.rb +6 -6
  12. data/app/controllers/devise/unlocks_controller.rb +2 -2
  13. data/app/controllers/devise_controller.rb +3 -3
  14. data/app/helpers/devise_helper.rb +2 -2
  15. data/app/views/devise/confirmations/new.html.erb +2 -2
  16. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  17. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  18. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  19. data/app/views/devise/passwords/edit.html.erb +3 -3
  20. data/app/views/devise/passwords/new.html.erb +2 -2
  21. data/app/views/devise/registrations/edit.html.erb +6 -6
  22. data/app/views/devise/registrations/new.html.erb +4 -4
  23. data/app/views/devise/sessions/new.html.erb +3 -3
  24. data/app/views/devise/unlocks/new.html.erb +2 -2
  25. data/devise.gemspec +1 -1
  26. data/gemfiles/Gemfile.rails-3.2-stable +3 -3
  27. data/gemfiles/Gemfile.rails-4.0-stable +3 -3
  28. data/gemfiles/Gemfile.rails-head +3 -3
  29. data/lib/devise.rb +3 -3
  30. data/lib/devise/controllers/helpers.rb +5 -5
  31. data/lib/devise/controllers/rememberable.rb +3 -3
  32. data/lib/devise/controllers/sign_in_out.rb +8 -8
  33. data/lib/devise/failure_app.rb +3 -3
  34. data/lib/devise/hooks/activatable.rb +1 -1
  35. data/lib/devise/hooks/lockable.rb +1 -1
  36. data/lib/devise/hooks/proxy.rb +1 -1
  37. data/lib/devise/hooks/rememberable.rb +1 -1
  38. data/lib/devise/hooks/timeoutable.rb +1 -1
  39. data/lib/devise/hooks/trackable.rb +1 -1
  40. data/lib/devise/mailers/helpers.rb +8 -8
  41. data/lib/devise/models/authenticatable.rb +3 -3
  42. data/lib/devise/models/confirmable.rb +9 -9
  43. data/lib/devise/models/database_authenticatable.rb +1 -1
  44. data/lib/devise/models/lockable.rb +6 -6
  45. data/lib/devise/models/omniauthable.rb +1 -1
  46. data/lib/devise/models/recoverable.rb +1 -1
  47. data/lib/devise/models/rememberable.rb +3 -3
  48. data/lib/devise/models/trackable.rb +1 -1
  49. data/lib/devise/models/validatable.rb +6 -6
  50. data/lib/devise/modules.rb +9 -9
  51. data/lib/devise/omniauth/url_helpers.rb +2 -2
  52. data/lib/devise/rails.rb +1 -1
  53. data/lib/devise/rails/routes.rb +81 -81
  54. data/lib/devise/test_helpers.rb +2 -2
  55. data/lib/devise/time_inflector.rb +1 -1
  56. data/lib/devise/version.rb +1 -1
  57. data/lib/generators/active_record/devise_generator.rb +6 -6
  58. data/lib/generators/active_record/templates/migration.rb +4 -4
  59. data/lib/generators/active_record/templates/migration_existing.rb +4 -4
  60. data/lib/generators/devise/devise_generator.rb +3 -3
  61. data/lib/generators/devise/views_generator.rb +29 -18
  62. data/lib/generators/mongoid/devise_generator.rb +19 -19
  63. data/lib/generators/templates/README +2 -2
  64. data/lib/generators/templates/devise.rb +9 -7
  65. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  66. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  67. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  68. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
  69. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
  70. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
  71. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
  72. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
  73. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
  74. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
  75. data/test/controllers/helpers_test.rb +31 -31
  76. data/test/controllers/internal_helpers_test.rb +6 -6
  77. data/test/controllers/sessions_controller_test.rb +18 -18
  78. data/test/controllers/url_helpers_test.rb +4 -4
  79. data/test/delegator_test.rb +1 -1
  80. data/test/devise_test.rb +3 -3
  81. data/test/failure_app_test.rb +21 -21
  82. data/test/generators/active_record_generator_test.rb +4 -4
  83. data/test/generators/devise_generator_test.rb +2 -2
  84. data/test/generators/mongoid_generator_test.rb +1 -1
  85. data/test/generators/views_generator_test.rb +30 -1
  86. data/test/helpers/devise_helper_test.rb +11 -11
  87. data/test/integration/authenticatable_test.rb +42 -42
  88. data/test/integration/confirmable_test.rb +46 -46
  89. data/test/integration/database_authenticatable_test.rb +16 -16
  90. data/test/integration/http_authenticatable_test.rb +11 -11
  91. data/test/integration/lockable_test.rb +37 -37
  92. data/test/integration/omniauthable_test.rb +3 -3
  93. data/test/integration/recoverable_test.rb +41 -41
  94. data/test/integration/registerable_test.rb +49 -49
  95. data/test/integration/rememberable_test.rb +13 -13
  96. data/test/integration/timeoutable_test.rb +7 -7
  97. data/test/integration/trackable_test.rb +2 -2
  98. data/test/mailers/confirmation_instructions_test.rb +4 -4
  99. data/test/mailers/reset_password_instructions_test.rb +3 -3
  100. data/test/mailers/unlock_instructions_test.rb +2 -2
  101. data/test/models/authenticatable_test.rb +3 -3
  102. data/test/models/confirmable_test.rb +31 -31
  103. data/test/models/database_authenticatable_test.rb +27 -27
  104. data/test/models/lockable_test.rb +29 -29
  105. data/test/models/recoverable_test.rb +19 -19
  106. data/test/models/rememberable_test.rb +8 -8
  107. data/test/models/serializable_test.rb +8 -8
  108. data/test/models/timeoutable_test.rb +1 -1
  109. data/test/models/validatable_test.rb +11 -11
  110. data/test/omniauth/config_test.rb +3 -3
  111. data/test/omniauth/url_helpers_test.rb +3 -3
  112. data/test/parameter_sanitizer_test.rb +1 -1
  113. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  114. data/test/rails_app/app/controllers/application_controller.rb +2 -2
  115. data/test/rails_app/app/controllers/home_controller.rb +1 -1
  116. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -2
  117. data/test/rails_app/app/controllers/users_controller.rb +5 -5
  118. data/test/rails_app/app/mailers/users/mailer.rb +4 -4
  119. data/test/rails_app/app/mongoid/admin.rb +11 -11
  120. data/test/rails_app/app/mongoid/shim.rb +2 -2
  121. data/test/rails_app/app/mongoid/user.rb +19 -19
  122. data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
  123. data/test/rails_app/app/views/layouts/application.html.erb +1 -1
  124. data/test/rails_app/config/application.rb +2 -2
  125. data/test/rails_app/config/initializers/devise.rb +3 -3
  126. data/test/rails_app/config/initializers/secret_token.rb +1 -1
  127. data/test/rails_app/config/routes.rb +43 -43
  128. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
  129. data/test/rails_app/lib/shared_admin.rb +4 -4
  130. data/test/routes_test.rb +59 -59
  131. data/test/support/helpers.rb +4 -4
  132. data/test/support/integration.rb +12 -12
  133. data/test/test_helpers_test.rb +3 -3
  134. data/test/test_models.rb +5 -5
  135. metadata +4 -4
@@ -1,10 +1,10 @@
1
1
  <h2>Resend unlock instructions</h2>
2
2
 
3
- <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
3
+ <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
4
4
  <%= devise_error_messages! %>
5
5
 
6
6
  <div><%= f.label :email %><br />
7
- <%= f.email_field :email, :autofocus => true %></div>
7
+ <%= f.email_field :email, autofocus: true %></div>
8
8
 
9
9
  <div><%= f.submit "Resend unlock instructions" %></div>
10
10
  <% end %>
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.add_dependency("warden", "~> 1.2.3")
23
23
  s.add_dependency("orm_adapter", "~> 0.1")
24
- s.add_dependency("bcrypt-ruby", "~> 3.0")
24
+ s.add_dependency("bcrypt", "~> 3.0")
25
25
  s.add_dependency("thread_safe", "~> 0.1")
26
26
  s.add_dependency("railties", ">= 3.2.6", "< 5")
27
27
  end
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec :path => '..'
3
+ gemspec path: '..'
4
4
 
5
5
  gem "rails", github: 'rails/rails', branch: '3-2-stable'
6
6
  gem "omniauth", "~> 1.0.0"
@@ -10,8 +10,8 @@ gem "rdoc"
10
10
  group :test do
11
11
  gem "omniauth-facebook"
12
12
  gem "omniauth-openid", "~> 1.0.1"
13
- gem "webrat", "0.7.3", :require => false
14
- gem "mocha", "~> 0.13.1", :require => false
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.0.0", require: false
15
15
  end
16
16
 
17
17
  platforms :jruby do
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec :path => '..'
3
+ gemspec path: '..'
4
4
 
5
5
  gem "rails", github: 'rails/rails', branch: '4-0-stable'
6
6
  gem "omniauth", "~> 1.0.0"
@@ -10,8 +10,8 @@ gem "rdoc"
10
10
  group :test do
11
11
  gem "omniauth-facebook"
12
12
  gem "omniauth-openid", "~> 1.0.1"
13
- gem "webrat", "0.7.3", :require => false
14
- gem "mocha", "~> 0.13.1", :require => false
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.0.0", require: false
15
15
  end
16
16
 
17
17
  platforms :jruby do
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gemspec :path => '..'
3
+ gemspec path: '..'
4
4
 
5
5
  gem "rails", github: 'rails/rails'
6
6
  gem "omniauth", "~> 1.0.0"
@@ -10,8 +10,8 @@ gem "rdoc"
10
10
  group :test do
11
11
  gem "omniauth-facebook"
12
12
  gem "omniauth-openid", "~> 1.0.1"
13
- gem "webrat", "0.7.3", :require => false
14
- gem "mocha", "~> 0.14", :require => false
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.0.0", require: false
15
15
  end
16
16
 
17
17
  platforms :jruby do
@@ -350,8 +350,8 @@ module Devise
350
350
  # == Examples:
351
351
  #
352
352
  # Devise.add_module(:party_module)
353
- # Devise.add_module(:party_module, :strategy => true, :controller => :sessions)
354
- # Devise.add_module(:party_module, :model => 'party_module/model')
353
+ # Devise.add_module(:party_module, strategy: true, controller: :sessions)
354
+ # Devise.add_module(:party_module, model: 'party_module/model')
355
355
  #
356
356
  def self.add_module(module_name, options = {})
357
357
  ALL << module_name
@@ -449,7 +449,7 @@ module Devise
449
449
  warden_config.intercept_401 = false
450
450
 
451
451
  Devise.mappings.each_value do |mapping|
452
- warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
452
+ warden_config.scope_defaults mapping.name, strategies: mapping.strategies
453
453
 
454
454
  warden_config.serialize_into_session(mapping.name) do |record|
455
455
  mapping.to.serialize_into_session(record)
@@ -55,7 +55,7 @@ module Devise
55
55
  end
56
56
 
57
57
  def current_#{mapping}
58
- @current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
58
+ @current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
59
59
  end
60
60
 
61
61
  def #{mapping}_session
@@ -77,9 +77,9 @@ module Devise
77
77
  # the controllers defined inside devise. Useful if you want to apply a before
78
78
  # filter to all controllers, except the ones in devise:
79
79
  #
80
- # before_filter :my_filter, :unless => :devise_controller?
80
+ # before_filter :my_filter, unless: :devise_controller?
81
81
  def devise_controller?
82
- is_a?(DeviseController)
82
+ is_a?(::DeviseController)
83
83
  end
84
84
 
85
85
  # Setup a param sanitizer to filter parameters using strong_parameters. See
@@ -121,10 +121,10 @@ module Devise
121
121
  # root path. For a user scope, you can define the default url in
122
122
  # the following way:
123
123
  #
124
- # map.user_root '/users', :controller => 'users' # creates user_root_path
124
+ # map.user_root '/users', controller: 'users' # creates user_root_path
125
125
  #
126
126
  # map.namespace :user do |user|
127
- # user.root :controller => 'users' # creates user_root_path
127
+ # user.root controller: 'users' # creates user_root_path
128
128
  # end
129
129
  #
130
130
  # If the resource root path is not defined, root_path is used. However,
@@ -31,11 +31,11 @@ module Devise
31
31
  end
32
32
 
33
33
  def remember_cookie_values(resource)
34
- options = { :httponly => true }
34
+ options = { httponly: true }
35
35
  options.merge!(forget_cookie_values(resource))
36
36
  options.merge!(
37
- :value => resource.class.serialize_into_cookie(resource),
38
- :expires => resource.remember_expires_at
37
+ value: resource.class.serialize_into_cookie(resource),
38
+ expires: resource.remember_expires_at
39
39
  )
40
40
  end
41
41
 
@@ -7,7 +7,7 @@ module Devise
7
7
  # true if any scope is signed in. Does not run authentication hooks.
8
8
  def signed_in?(scope=nil)
9
9
  [ scope || Devise.mappings.keys ].flatten.any? do |_scope|
10
- warden.authenticate?(:scope => _scope)
10
+ warden.authenticate?(scope: _scope)
11
11
  end
12
12
  end
13
13
 
@@ -23,9 +23,9 @@ module Devise
23
23
  #
24
24
  # sign_in :user, @user # sign_in(scope, resource)
25
25
  # sign_in @user # sign_in(resource)
26
- # sign_in @user, :event => :authentication # sign_in(resource, options)
27
- # sign_in @user, :store => false # sign_in(resource, options)
28
- # sign_in @user, :bypass => true # sign_in(resource, options)
26
+ # sign_in @user, event: :authentication # sign_in(resource, options)
27
+ # sign_in @user, store: false # sign_in(resource, options)
28
+ # sign_in @user, bypass: true # sign_in(resource, options)
29
29
  #
30
30
  def sign_in(resource_or_scope, *args)
31
31
  options = args.extract_options!
@@ -40,7 +40,7 @@ module Devise
40
40
  # Do nothing. User already signed in and we are not forcing it.
41
41
  true
42
42
  else
43
- warden.set_user(resource, options.merge!(:scope => scope))
43
+ warden.set_user(resource, options.merge!(scope: scope))
44
44
  end
45
45
  end
46
46
 
@@ -56,11 +56,11 @@ module Devise
56
56
  def sign_out(resource_or_scope=nil)
57
57
  return sign_out_all_scopes unless resource_or_scope
58
58
  scope = Devise::Mapping.find_scope!(resource_or_scope)
59
- user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
59
+ user = warden.user(scope: scope, run_callbacks: false) # If there is no user
60
60
 
61
61
  warden.raw_session.inspect # Without this inspect here. The session does not clear.
62
62
  warden.logout(scope)
63
- warden.clear_strategies_cache!(:scope => scope)
63
+ warden.clear_strategies_cache!(scope: scope)
64
64
  instance_variable_set(:"@current_#{scope}", nil)
65
65
 
66
66
  !!user
@@ -70,7 +70,7 @@ module Devise
70
70
  # in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
71
71
  # and false if there was no user logged in on all scopes.
72
72
  def sign_out_all_scopes(lock=true)
73
- users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
73
+ users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
74
74
 
75
75
  warden.raw_session.inspect
76
76
  warden.logout
@@ -15,7 +15,7 @@ module Devise
15
15
 
16
16
  include Devise::Controllers::StoreLocation
17
17
 
18
- delegate :flash, :to => :request
18
+ delegate :flash, to: :request
19
19
 
20
20
  def self.call(env)
21
21
  @respond ||= action(:respond)
@@ -151,9 +151,9 @@ module Devise
151
151
  return i18n_message unless request_format
152
152
  method = "to_#{request_format}"
153
153
  if method == "to_xml"
154
- { :error => i18n_message }.to_xml(:root => "errors")
154
+ { error: i18n_message }.to_xml(root: "errors")
155
155
  elsif {}.respond_to?(method)
156
- { :error => i18n_message }.send(method)
156
+ { error: i18n_message }.send(method)
157
157
  else
158
158
  i18n_message
159
159
  end
@@ -6,6 +6,6 @@ Warden::Manager.after_set_user do |record, warden, options|
6
6
  if record && record.respond_to?(:active_for_authentication?) && !record.active_for_authentication?
7
7
  scope = options[:scope]
8
8
  warden.logout(scope)
9
- throw :warden, :scope => scope, :message => record.inactive_message
9
+ throw :warden, scope: scope, message: record.inactive_message
10
10
  end
11
11
  end
@@ -1,6 +1,6 @@
1
1
  # After each sign in, if resource responds to failed_attempts, sets it to 0
2
2
  # This is only triggered when the user is explicitly set (with set_user)
3
- Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
3
+ Warden::Manager.after_set_user except: :fetch do |record, warden, options|
4
4
  if record.respond_to?(:failed_attempts) && warden.authenticated?(options[:scope])
5
5
  record.update_attribute(:failed_attempts, 0) unless record.failed_attempts.to_i.zero?
6
6
  end
@@ -7,7 +7,7 @@ module Devise
7
7
  include Devise::Controllers::SignInOut
8
8
 
9
9
  attr_reader :warden
10
- delegate :cookies, :env, :to => :warden
10
+ delegate :cookies, :env, to: :warden
11
11
 
12
12
  def initialize(warden)
13
13
  @warden = warden
@@ -1,4 +1,4 @@
1
- Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
1
+ Warden::Manager.after_set_user except: :fetch do |record, warden, options|
2
2
  scope = options[:scope]
3
3
  if record.respond_to?(:remember_me) && options[:store] != false &&
4
4
  record.remember_me && warden.authenticated?(scope)
@@ -18,7 +18,7 @@ Warden::Manager.after_set_user do |record, warden, options|
18
18
  record.reset_authentication_token!
19
19
  end
20
20
 
21
- throw :warden, :scope => scope, :message => :timeout
21
+ throw :warden, scope: scope, message: :timeout
22
22
  end
23
23
 
24
24
  unless env['devise.skip_trackable']
@@ -2,7 +2,7 @@
2
2
  # This is only triggered when the user is explicitly set (with set_user)
3
3
  # and on authentication. Retrieving the user from session (:fetch) does
4
4
  # not trigger it.
5
- Warden::Manager.after_set_user :except => :fetch do |record, warden, options|
5
+ Warden::Manager.after_set_user except: :fetch do |record, warden, options|
6
6
  if record.respond_to?(:update_tracked_fields!) && warden.authenticated?(options[:scope]) && !warden.request.env['devise.skip_trackable']
7
7
  record.update_tracked_fields!(warden.request)
8
8
  end
@@ -27,12 +27,12 @@ module Devise
27
27
 
28
28
  def headers_for(action, opts)
29
29
  headers = {
30
- :subject => subject_for(action),
31
- :to => resource.email,
32
- :from => mailer_sender(devise_mapping),
33
- :reply_to => mailer_reply_to(devise_mapping),
34
- :template_path => template_paths,
35
- :template_name => action
30
+ subject: subject_for(action),
31
+ to: resource.email,
32
+ from: mailer_sender(devise_mapping),
33
+ reply_to: mailer_reply_to(devise_mapping),
34
+ template_path: template_paths,
35
+ template_name: action
36
36
  }.merge(opts)
37
37
 
38
38
  @email = headers[:to]
@@ -82,8 +82,8 @@ module Devise
82
82
  # subject: '...'
83
83
  #
84
84
  def subject_for(key)
85
- I18n.t(:"#{devise_mapping.name}_subject", :scope => [:devise, :mailer, key],
86
- :default => [:subject, key.to_s.humanize])
85
+ I18n.t(:"#{devise_mapping.name}_subject", scope: [:devise, :mailer, key],
86
+ default: [:subject, key.to_s.humanize])
87
87
  end
88
88
  end
89
89
  end
@@ -29,7 +29,7 @@ module Devise
29
29
  # It also accepts an array specifying the strategies that should allow params authentication.
30
30
  #
31
31
  # * +skip_session_storage+: By default Devise will store the user in session.
32
- # By default is set to :skip_session_storage => [:http_auth].
32
+ # By default is set to skip_session_storage: [:http_auth].
33
33
  #
34
34
  # == active_for_authentication?
35
35
  #
@@ -59,7 +59,7 @@ module Devise
59
59
  :remember_token, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
60
60
 
61
61
  included do
62
- class_attribute :devise_modules, :instance_writer => false
62
+ class_attribute :devise_modules, instance_writer: false
63
63
  self.devise_modules ||= []
64
64
 
65
65
  before_validation :downcase_keys
@@ -231,7 +231,7 @@ module Devise
231
231
  # Example:
232
232
  #
233
233
  # def self.find_for_authentication(tainted_conditions)
234
- # find_first_by_auth_conditions(tainted_conditions, :active => true)
234
+ # find_first_by_auth_conditions(tainted_conditions, active: true)
235
235
  # end
236
236
  #
237
237
  # Finally, notice that Devise also queries for users in other scenarios
@@ -33,10 +33,10 @@ module Devise
33
33
  include ActionView::Helpers::DateHelper
34
34
 
35
35
  included do
36
- before_create :generate_confirmation_token, :if => :confirmation_required?
37
- after_create :send_on_create_confirmation_instructions, :if => :send_confirmation_notification?
38
- before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, :if => :postpone_email_change?
39
- after_update :send_reconfirmation_instructions, :if => :reconfirmation_required?
36
+ before_create :generate_confirmation_token, if: :confirmation_required?
37
+ after_create :send_on_create_confirmation_instructions, if: :send_confirmation_notification?
38
+ before_update :postpone_email_change_until_confirmation_and_regenerate_confirmation_token, if: :postpone_email_change?
39
+ after_update :send_reconfirmation_instructions, if: :reconfirmation_required?
40
40
  end
41
41
 
42
42
  def initialize(*args, &block)
@@ -60,7 +60,7 @@ module Devise
60
60
  pending_any_confirmation do
61
61
  if confirmation_period_expired?
62
62
  self.errors.add(:email, :confirmation_period_expired,
63
- :period => Devise::TimeInflector.time_ago_in_words(self.class.confirm_within.ago))
63
+ period: Devise::TimeInflector.time_ago_in_words(self.class.confirm_within.ago))
64
64
  return false
65
65
  end
66
66
 
@@ -73,9 +73,9 @@ module Devise
73
73
  self.unconfirmed_email = nil
74
74
 
75
75
  # We need to validate in such cases to enforce e-mail uniqueness
76
- save(:validate => true)
76
+ save(validate: true)
77
77
  else
78
- save(:validate => false)
78
+ save(validate: false)
79
79
  end
80
80
 
81
81
  after_confirmation if saved
@@ -98,7 +98,7 @@ module Devise
98
98
  generate_confirmation_token!
99
99
  end
100
100
 
101
- opts = pending_reconfirmation? ? { :to => unconfirmed_email } : { }
101
+ opts = pending_reconfirmation? ? { to: unconfirmed_email } : { }
102
102
  send_devise_notification(:confirmation_instructions, @raw_confirmation_token, opts)
103
103
  end
104
104
 
@@ -225,7 +225,7 @@ module Devise
225
225
  end
226
226
 
227
227
  def generate_confirmation_token!
228
- generate_confirmation_token && save(:validate => false)
228
+ generate_confirmation_token && save(validate: false)
229
229
  end
230
230
 
231
231
  def postpone_email_change_until_confirmation_and_regenerate_confirmation_token
@@ -4,7 +4,7 @@ require 'bcrypt'
4
4
  module Devise
5
5
  # Digests the password using bcrypt.
6
6
  def self.bcrypt(klass, password)
7
- ::BCrypt::Password.create("#{password}#{klass.pepper}", :cost => klass.stretches).to_s
7
+ ::BCrypt::Password.create("#{password}#{klass.pepper}", cost: klass.stretches).to_s
8
8
  end
9
9
 
10
10
  module Models
@@ -22,7 +22,7 @@ module Devise
22
22
  module Lockable
23
23
  extend ActiveSupport::Concern
24
24
 
25
- delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, :to => "self.class"
25
+ delegate :lock_strategy_enabled?, :unlock_strategy_enabled?, to: "self.class"
26
26
 
27
27
  def self.required_fields(klass)
28
28
  attributes = []
@@ -36,14 +36,14 @@ module Devise
36
36
  # Lock a user setting its locked_at to actual time.
37
37
  # * +opts+: Hash options if you don't want to send email
38
38
  # when you lock access, you could pass the next hash
39
- # `{ :send_instructions => false } as option`.
39
+ # `{ send_instructions: false } as option`.
40
40
  def lock_access!(opts = { })
41
41
  self.locked_at = Time.now.utc
42
42
 
43
43
  if unlock_strategy_enabled?(:email) && opts.fetch(:send_instructions, true)
44
44
  send_unlock_instructions
45
45
  else
46
- save(:validate => false)
46
+ save(validate: false)
47
47
  end
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ module Devise
52
52
  self.locked_at = nil
53
53
  self.failed_attempts = 0 if respond_to?(:failed_attempts=)
54
54
  self.unlock_token = nil if respond_to?(:unlock_token=)
55
- save(:validate => false)
55
+ save(validate: false)
56
56
  end
57
57
 
58
58
  # Verifies whether a user is locked or not.
@@ -64,7 +64,7 @@ module Devise
64
64
  def send_unlock_instructions
65
65
  raw, enc = Devise.token_generator.generate(self.class, :unlock_token)
66
66
  self.unlock_token = enc
67
- self.save(:validate => false)
67
+ self.save(validate: false)
68
68
  send_devise_notification(:unlock_instructions, raw, {})
69
69
  raw
70
70
  end
@@ -104,7 +104,7 @@ module Devise
104
104
  if attempts_exceeded?
105
105
  lock_access! unless access_locked?
106
106
  else
107
- save(:validate => false)
107
+ save(validate: false)
108
108
  end
109
109
  false
110
110
  end