loyal_devise 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +14 -9
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.rdoc +60 -5
  5. data/CONTRIBUTING.md +4 -2
  6. data/Gemfile +7 -7
  7. data/Gemfile.lock +107 -101
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +110 -48
  10. data/Rakefile +1 -0
  11. data/app/controllers/devise/confirmations_controller.rb +2 -4
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
  13. data/app/controllers/devise/passwords_controller.rb +16 -5
  14. data/app/controllers/devise/registrations_controller.rb +13 -7
  15. data/app/controllers/devise/sessions_controller.rb +6 -6
  16. data/app/controllers/devise/unlocks_controller.rb +3 -4
  17. data/app/controllers/devise_controller.rb +12 -33
  18. data/app/helpers/devise_helper.rb +0 -1
  19. data/app/mailers/devise/mailer.rb +7 -8
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  22. data/app/views/devise/registrations/edit.html.erb +5 -1
  23. data/config/locales/en.yml +48 -48
  24. data/devise.gemspec +6 -6
  25. data/devise.png +0 -0
  26. data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
  27. data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
  28. data/lib/devise.rb +34 -11
  29. data/lib/devise/controllers/helpers.rb +33 -7
  30. data/lib/devise/controllers/rememberable.rb +6 -3
  31. data/lib/devise/controllers/scoped_views.rb +1 -2
  32. data/lib/devise/controllers/url_helpers.rb +0 -1
  33. data/lib/devise/delegator.rb +0 -1
  34. data/lib/devise/failure_app.rb +8 -2
  35. data/lib/devise/hooks/activatable.rb +1 -2
  36. data/lib/devise/hooks/forgetable.rb +0 -1
  37. data/lib/devise/hooks/lockable.rb +1 -2
  38. data/lib/devise/hooks/rememberable.rb +1 -2
  39. data/lib/devise/hooks/timeoutable.rb +0 -1
  40. data/lib/devise/hooks/trackable.rb +0 -1
  41. data/lib/devise/mailers/helpers.rb +18 -14
  42. data/lib/devise/mapping.rb +6 -7
  43. data/lib/devise/models.rb +0 -1
  44. data/lib/devise/models/authenticatable.rb +50 -27
  45. data/lib/devise/models/confirmable.rb +37 -16
  46. data/lib/devise/models/database_authenticatable.rb +17 -3
  47. data/lib/devise/models/lockable.rb +1 -2
  48. data/lib/devise/models/omniauthable.rb +1 -2
  49. data/lib/devise/models/recoverable.rb +10 -6
  50. data/lib/devise/models/registerable.rb +0 -1
  51. data/lib/devise/models/rememberable.rb +1 -2
  52. data/lib/devise/models/timeoutable.rb +1 -2
  53. data/lib/devise/models/token_authenticatable.rb +0 -1
  54. data/lib/devise/models/trackable.rb +0 -1
  55. data/lib/devise/models/validatable.rb +0 -1
  56. data/lib/devise/modules.rb +1 -2
  57. data/lib/devise/omniauth.rb +0 -1
  58. data/lib/devise/omniauth/config.rb +0 -1
  59. data/lib/devise/omniauth/url_helpers.rb +0 -1
  60. data/lib/devise/orm/active_record.rb +1 -2
  61. data/lib/devise/orm/mongoid.rb +1 -2
  62. data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
  63. data/lib/devise/parameter_sanitizer.rb +59 -0
  64. data/lib/devise/rails.rb +0 -1
  65. data/lib/devise/rails/routes.rb +22 -18
  66. data/lib/devise/rails/warden_compat.rb +0 -30
  67. data/lib/devise/strategies/authenticatable.rb +8 -6
  68. data/lib/devise/strategies/base.rb +1 -2
  69. data/lib/devise/strategies/database_authenticatable.rb +1 -2
  70. data/lib/devise/strategies/rememberable.rb +1 -2
  71. data/lib/devise/strategies/token_authenticatable.rb +38 -4
  72. data/lib/devise/test_helpers.rb +0 -1
  73. data/lib/devise/time_inflector.rb +1 -2
  74. data/lib/devise/version.rb +1 -2
  75. data/lib/generators/active_record/devise_generator.rb +1 -5
  76. data/lib/generators/active_record/templates/migration.rb +0 -1
  77. data/lib/generators/active_record/templates/migration_existing.rb +0 -1
  78. data/lib/generators/devise/devise_generator.rb +0 -1
  79. data/lib/generators/devise/install_generator.rb +0 -1
  80. data/lib/generators/devise/orm_helpers.rb +1 -2
  81. data/lib/generators/devise/views_generator.rb +8 -3
  82. data/lib/generators/mongoid/devise_generator.rb +1 -2
  83. data/lib/generators/templates/README +1 -1
  84. data/lib/generators/templates/devise.rb +10 -5
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
  87. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
  88. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
  89. data/loyal_devise.gemspec +27 -0
  90. data/test/controllers/custom_strategy_test.rb +0 -1
  91. data/test/controllers/helpers_test.rb +0 -1
  92. data/test/controllers/internal_helpers_test.rb +13 -4
  93. data/test/controllers/passwords_controller_test.rb +32 -0
  94. data/test/controllers/sessions_controller_test.rb +28 -1
  95. data/test/controllers/url_helpers_test.rb +0 -1
  96. data/test/delegator_test.rb +0 -1
  97. data/test/devise_test.rb +12 -2
  98. data/test/failure_app_test.rb +3 -4
  99. data/test/generators/active_record_generator_test.rb +1 -4
  100. data/test/generators/devise_generator_test.rb +0 -1
  101. data/test/generators/install_generator_test.rb +0 -1
  102. data/test/generators/mongoid_generator_test.rb +0 -1
  103. data/test/generators/views_generator_test.rb +16 -2
  104. data/test/helpers/devise_helper_test.rb +1 -2
  105. data/test/integration/authenticatable_test.rb +92 -27
  106. data/test/integration/confirmable_test.rb +7 -7
  107. data/test/integration/database_authenticatable_test.rb +8 -7
  108. data/test/integration/http_authenticatable_test.rb +19 -2
  109. data/test/integration/lockable_test.rb +1 -2
  110. data/test/integration/omniauthable_test.rb +2 -3
  111. data/test/integration/recoverable_test.rb +40 -12
  112. data/test/integration/registerable_test.rb +17 -14
  113. data/test/integration/rememberable_test.rb +16 -10
  114. data/test/integration/timeoutable_test.rb +11 -2
  115. data/test/integration/token_authenticatable_test.rb +45 -2
  116. data/test/integration/trackable_test.rb +1 -2
  117. data/test/mailers/confirmation_instructions_test.rb +11 -3
  118. data/test/mailers/reset_password_instructions_test.rb +11 -3
  119. data/test/mailers/unlock_instructions_test.rb +11 -2
  120. data/test/mapping_test.rb +0 -1
  121. data/test/models/authenticatable_test.rb +6 -1
  122. data/test/models/confirmable_test.rb +53 -2
  123. data/test/models/database_authenticatable_test.rb +57 -21
  124. data/test/models/lockable_test.rb +1 -2
  125. data/test/models/omniauthable_test.rb +0 -1
  126. data/test/models/recoverable_test.rb +21 -5
  127. data/test/models/registerable_test.rb +0 -1
  128. data/test/models/rememberable_test.rb +4 -4
  129. data/test/models/serializable_test.rb +8 -8
  130. data/test/models/timeoutable_test.rb +0 -1
  131. data/test/models/token_authenticatable_test.rb +0 -1
  132. data/test/models/trackable_test.rb +0 -1
  133. data/test/models/validatable_test.rb +16 -6
  134. data/test/models_test.rb +7 -24
  135. data/test/omniauth/config_test.rb +1 -2
  136. data/test/omniauth/url_helpers_test.rb +4 -2
  137. data/test/orm/active_record.rb +1 -1
  138. data/test/orm/mongoid.rb +2 -4
  139. data/test/parameter_sanitizer_test.rb +51 -0
  140. data/test/rails_app/Rakefile +0 -4
  141. data/test/rails_app/app/active_record/admin.rb +0 -1
  142. data/test/rails_app/app/active_record/shim.rb +1 -2
  143. data/test/rails_app/app/active_record/user.rb +0 -1
  144. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
  145. data/test/rails_app/app/controllers/admins_controller.rb +0 -1
  146. data/test/rails_app/app/controllers/application_controller.rb +1 -1
  147. data/test/rails_app/app/controllers/home_controller.rb +0 -1
  148. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
  149. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
  150. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
  151. data/test/rails_app/app/controllers/users_controller.rb +8 -1
  152. data/test/rails_app/app/helpers/application_helper.rb +0 -1
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -1
  154. data/test/rails_app/app/mongoid/admin.rb +4 -3
  155. data/test/rails_app/app/mongoid/shim.rb +3 -5
  156. data/test/rails_app/app/mongoid/user.rb +2 -3
  157. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  158. data/test/rails_app/bin/bundle +3 -0
  159. data/test/rails_app/bin/rails +4 -0
  160. data/test/rails_app/bin/rake +4 -0
  161. data/test/rails_app/config/application.rb +1 -3
  162. data/test/rails_app/config/boot.rb +3 -4
  163. data/test/rails_app/config/environment.rb +2 -3
  164. data/test/rails_app/config/environments/development.rb +23 -8
  165. data/test/rails_app/config/environments/production.rb +68 -18
  166. data/test/rails_app/config/environments/test.rb +18 -16
  167. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
  168. data/test/rails_app/config/initializers/devise.rb +0 -1
  169. data/test/rails_app/config/initializers/inflections.rb +0 -1
  170. data/test/rails_app/config/initializers/secret_token.rb +8 -3
  171. data/test/rails_app/config/initializers/session_store.rb +1 -0
  172. data/test/rails_app/config/routes.rb +20 -17
  173. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
  174. data/test/rails_app/db/schema.rb +0 -1
  175. data/test/rails_app/lib/shared_admin.rb +0 -1
  176. data/test/rails_app/lib/shared_user.rb +0 -2
  177. data/test/routes_test.rb +22 -21
  178. data/test/support/assertions.rb +0 -1
  179. data/test/support/helpers.rb +1 -2
  180. data/test/support/integration.rb +0 -1
  181. data/test/support/webrat/integrations/rails.rb +0 -1
  182. data/test/test_helper.rb +8 -2
  183. data/test/test_helpers_test.rb +0 -1
  184. data/test/test_models.rb +26 -0
  185. metadata +65 -27
  186. data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
  187. data/test/indifferent_hash.rb +0 -34
  188. data/test/rails_app/script/rails +0 -10
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ Rake::TestTask.new(:test) do |t|
22
22
  t.libs << 'test'
23
23
  t.pattern = 'test/**/*_test.rb'
24
24
  t.verbose = true
25
+ t.warning = false
25
26
  end
26
27
 
27
28
  desc 'Generate documentation for Devise.'
@@ -1,8 +1,7 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::ConfirmationsController < DeviseController
3
2
  # GET /resource/confirmation/new
4
3
  def new
5
- build_resource({})
4
+ self.resource = resource_class.new
6
5
  end
7
6
 
8
7
  # POST /resource/confirmation
@@ -33,12 +32,11 @@ class Devise::ConfirmationsController < DeviseController
33
32
 
34
33
  # The path used after resending confirmation instructions.
35
34
  def after_resending_confirmation_instructions_path_for(resource_name)
36
- new_session_path(resource_name)
35
+ new_session_path(resource_name) if is_navigational_format?
37
36
  end
38
37
 
39
38
  # The path used after confirmation.
40
39
  def after_confirmation_path_for(resource_name, resource)
41
40
  after_sign_in_path_for(resource)
42
41
  end
43
-
44
42
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::OmniauthCallbacksController < DeviseController
3
2
  prepend_before_filter { request.env["devise.skip_timeout"] = true }
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::PasswordsController < DeviseController
3
2
  prepend_before_filter :require_no_authentication
4
3
  # Render the #edit only if coming from a reset password email link
@@ -6,7 +5,7 @@ class Devise::PasswordsController < DeviseController
6
5
 
7
6
  # GET /resource/password/new
8
7
  def new
9
- build_resource({})
8
+ self.resource = resource_class.new
10
9
  end
11
10
 
12
11
  # POST /resource/password
@@ -31,27 +30,39 @@ class Devise::PasswordsController < DeviseController
31
30
  self.resource = resource_class.reset_password_by_token(resource_params)
32
31
 
33
32
  if resource.errors.empty?
33
+ resource.unlock_access! if unlockable?(resource)
34
34
  flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
35
35
  set_flash_message(:notice, flash_message) if is_navigational_format?
36
36
  sign_in(resource_name, resource)
37
- respond_with resource, :location => after_sign_in_path_for(resource)
37
+ respond_with resource, :location => after_resetting_password_path_for(resource)
38
38
  else
39
39
  respond_with resource
40
40
  end
41
41
  end
42
42
 
43
43
  protected
44
+ def after_resetting_password_path_for(resource)
45
+ after_sign_in_path_for(resource)
46
+ end
44
47
 
45
48
  # The path used after sending reset password instructions
46
49
  def after_sending_reset_password_instructions_path_for(resource_name)
47
- new_session_path(resource_name)
50
+ new_session_path(resource_name) if is_navigational_format?
48
51
  end
49
52
 
50
53
  # Check if a reset_password_token is provided in the request
51
54
  def assert_reset_token_passed
52
55
  if params[:reset_password_token].blank?
53
- set_flash_message(:error, :no_token)
56
+ set_flash_message(:alert, :no_token)
54
57
  redirect_to new_session_path(resource_name)
55
58
  end
56
59
  end
60
+
61
+ # Check if proper Lockable module methods are present & unlock strategy
62
+ # allows to unlock resource on password reset
63
+ def unlockable?(resource)
64
+ resource.respond_to?(:unlock_access!) &&
65
+ resource.respond_to?(:unlock_strategy_enabled?) &&
66
+ resource.unlock_strategy_enabled?(:email)
67
+ end
57
68
  end
@@ -1,17 +1,16 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::RegistrationsController < DeviseController
3
2
  prepend_before_filter :require_no_authentication, :only => [ :new, :create, :cancel ]
4
3
  prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
5
4
 
6
5
  # GET /resource/sign_up
7
6
  def new
8
- resource = build_resource({})
9
- respond_with resource
7
+ build_resource({})
8
+ respond_with self.resource
10
9
  end
11
10
 
12
11
  # POST /resource
13
12
  def create
14
- build_resource
13
+ build_resource(sign_up_params)
15
14
 
16
15
  if resource.save
17
16
  if resource.active_for_authentication?
@@ -41,7 +40,7 @@ class Devise::RegistrationsController < DeviseController
41
40
  self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
42
41
  prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
43
42
 
44
- if resource.update_with_password(resource_params)
43
+ if resource.update_with_password(account_update_params)
45
44
  if is_navigational_format?
46
45
  flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
47
46
  :update_needs_confirmation : :updated
@@ -84,8 +83,7 @@ class Devise::RegistrationsController < DeviseController
84
83
  # Build a devise resource passing in the session. Useful to move
85
84
  # temporary session data to the newly created user.
86
85
  def build_resource(hash=nil)
87
- hash ||= resource_params || {}
88
- self.resource = resource_class.new_with_session(hash, session)
86
+ self.resource = resource_class.new_with_session(hash || {}, session)
89
87
  end
90
88
 
91
89
  # Signs in a user on sign up. You can overwrite this method in your own
@@ -117,4 +115,12 @@ class Devise::RegistrationsController < DeviseController
117
115
  send(:"authenticate_#{resource_name}!", :force => true)
118
116
  self.resource = send(:"current_#{resource_name}")
119
117
  end
118
+
119
+ def sign_up_params
120
+ devise_parameter_sanitizer.for(:sign_up)
121
+ end
122
+
123
+ def account_update_params
124
+ devise_parameter_sanitizer.for(:account_update)
125
+ end
120
126
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::SessionsController < DeviseController
3
2
  prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
4
3
  prepend_before_filter :allow_params_authentication!, :only => :create
@@ -6,7 +5,7 @@ class Devise::SessionsController < DeviseController
6
5
 
7
6
  # GET /resource/sign_in
8
7
  def new
9
- self.resource = build_resource(nil, :unsafe => true)
8
+ self.resource = resource_class.new(sign_in_params)
10
9
  clean_up_passwords(resource)
11
10
  respond_with(resource, serialize_options(resource))
12
11
  end
@@ -28,15 +27,17 @@ class Devise::SessionsController < DeviseController
28
27
  # We actually need to hardcode this as Rails default responder doesn't
29
28
  # support returning empty response on GET request
30
29
  respond_to do |format|
30
+ format.all { head :no_content }
31
31
  format.any(*navigational_formats) { redirect_to redirect_path }
32
- format.all do
33
- head :no_content
34
- end
35
32
  end
36
33
  end
37
34
 
38
35
  protected
39
36
 
37
+ def sign_in_params
38
+ devise_parameter_sanitizer.for(:sign_in)
39
+ end
40
+
40
41
  def serialize_options(resource)
41
42
  methods = resource_class.authentication_keys.dup
42
43
  methods = methods.keys if methods.is_a?(Hash)
@@ -48,4 +49,3 @@ class Devise::SessionsController < DeviseController
48
49
  { :scope => resource_name, :recall => "#{controller_path}#new" }
49
50
  end
50
51
  end
51
-
@@ -1,10 +1,9 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Devise::UnlocksController < DeviseController
3
2
  prepend_before_filter :require_no_authentication
4
3
 
5
4
  # GET /resource/unlock/new
6
5
  def new
7
- build_resource({})
6
+ self.resource = resource_class.new
8
7
  end
9
8
 
10
9
  # POST /resource/unlock
@@ -34,12 +33,12 @@ class Devise::UnlocksController < DeviseController
34
33
 
35
34
  # The path used after sending unlock password instructions
36
35
  def after_sending_unlock_instructions_path_for(resource)
37
- new_session_path(resource)
36
+ new_session_path(resource) if is_navigational_format?
38
37
  end
39
38
 
40
39
  # The path used after unlocking the resource
41
40
  def after_unlock_path_for(resource)
42
- new_session_path(resource)
41
+ new_session_path(resource) if is_navigational_format?
43
42
  end
44
43
 
45
44
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # All Devise controllers are inherited from here.
3
2
  class DeviseController < Devise.parent_controller.constantize
4
3
  include Devise::Controllers::ScopedViews
@@ -11,7 +10,7 @@ class DeviseController < Devise.parent_controller.constantize
11
10
  helper_method *helpers
12
11
 
13
12
  prepend_before_filter :assert_is_devise_resource!
14
- respond_to *Mime::SET.map(&:to_sym) if mimes_for_respond_to.empty?
13
+ respond_to :html if mimes_for_respond_to.empty?
15
14
 
16
15
  # Gets the actual resource stored in the instance variable
17
16
  def resource
@@ -29,10 +28,6 @@ class DeviseController < Devise.parent_controller.constantize
29
28
  devise_mapping.to
30
29
  end
31
30
 
32
- def resource_params
33
- params[resource_name]
34
- end
35
-
36
31
  # Returns a signed in resource from session (if one exists)
37
32
  def signed_in_resource
38
33
  warden.authenticate(:scope => resource_name)
@@ -68,7 +63,7 @@ This may happen for two reasons:
68
63
  1) You forgot to wrap your route inside the scope block. For example:
69
64
 
70
65
  devise_scope :user do
71
- match "/some/route" => "some_devise_controller"
66
+ get "/some/route" => "some_devise_controller"
72
67
  end
73
68
 
74
69
  2) You are testing a Devise controller bypassing the router.
@@ -94,23 +89,6 @@ MESSAGE
94
89
  instance_variable_set(:"@#{resource_name}", new_resource)
95
90
  end
96
91
 
97
- # Build a devise resource.
98
- # Assignment bypasses attribute protection when :unsafe option is passed
99
- def build_resource(hash = nil, options = {})
100
- hash ||= resource_params || {}
101
-
102
- if options[:unsafe]
103
- self.resource = resource_class.new.tap do |resource|
104
- hash.each do |key, value|
105
- setter = :"#{key}="
106
- resource.send(setter, value) if resource.respond_to?(setter)
107
- end
108
- end
109
- else
110
- self.resource = resource_class.new(hash)
111
- end
112
- end
113
-
114
92
  # Helper for use in before_filters where no authentication is required.
115
93
  #
116
94
  # Example:
@@ -164,13 +142,18 @@ MESSAGE
164
142
  #
165
143
  # Please refer to README or en.yml locale file to check what messages are
166
144
  # available.
167
- def set_flash_message(key, kind, options={})
145
+ def set_flash_message(key, kind, options = {})
146
+ message = find_message(kind, options)
147
+ flash[key] = message if message.present?
148
+ end
149
+
150
+ # Get message for given
151
+ def find_message(kind, options = {})
168
152
  options[:scope] = "devise.#{controller_name}"
169
153
  options[:default] = Array(options[:default]).unshift(kind.to_sym)
170
154
  options[:resource_name] = resource_name
171
155
  options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
172
- message = I18n.t("#{options[:resource_name]}.#{kind}", options)
173
- flash[key] = message if message.present?
156
+ I18n.t("#{options[:resource_name]}.#{kind}", options)
174
157
  end
175
158
 
176
159
  def clean_up_passwords(object)
@@ -183,11 +166,7 @@ MESSAGE
183
166
  end
184
167
  end
185
168
 
186
- def request_format
187
- @request_format ||= request.format.try(:ref)
188
- end
189
-
190
- def is_navigational_format?
191
- Devise.navigational_formats.include?(request_format)
169
+ def resource_params
170
+ params.fetch(resource_name, {})
192
171
  end
193
172
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module DeviseHelper
3
2
  # A simple way to show error messages for the current devise resource. If you need
4
3
  # to customize this method, you can either overwrite it in your application helpers or
@@ -1,16 +1,15 @@
1
- # -*- encoding : utf-8 -*-
2
- class Devise::Mailer < ::ActionMailer::Base
1
+ class Devise::Mailer < Devise.parent_mailer.constantize
3
2
  include Devise::Mailers::Helpers
4
3
 
5
- def confirmation_instructions(record)
6
- devise_mail(record, :confirmation_instructions)
4
+ def confirmation_instructions(record, opts={})
5
+ devise_mail(record, :confirmation_instructions, opts)
7
6
  end
8
7
 
9
- def reset_password_instructions(record)
10
- devise_mail(record, :reset_password_instructions)
8
+ def reset_password_instructions(record, opts={})
9
+ devise_mail(record, :reset_password_instructions, opts)
11
10
  end
12
11
 
13
- def unlock_instructions(record)
14
- devise_mail(record, :unlock_instructions)
12
+ def unlock_instructions(record, opts={})
13
+ devise_mail(record, :unlock_instructions, opts)
15
14
  end
16
15
  end
@@ -1,4 +1,4 @@
1
- <p>Welcome <%= @resource.email %>!</p>
1
+ <p>Welcome <%= @email %>!</p>
2
2
 
3
3
  <p>You can confirm your account email through the link below:</p>
4
4
 
@@ -1,6 +1,6 @@
1
1
  <p>Hello <%= @resource.email %>!</p>
2
2
 
3
- <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
3
+ <p>Someone has requested a link to change your password. You can do this through the link below.</p>
4
4
 
5
5
  <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
6
 
@@ -6,6 +6,10 @@
6
6
  <div><%= f.label :email %><br />
7
7
  <%= f.email_field :email, :autofocus => true %></div>
8
8
 
9
+ <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
10
+ <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
11
+ <% end %>
12
+
9
13
  <div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
10
14
  <%= f.password_field :password, :autocomplete => "off" %></div>
11
15
 
@@ -20,6 +24,6 @@
20
24
 
21
25
  <h3>Cancel my account</h3>
22
26
 
23
- <p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
27
+ <p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
24
28
 
25
29
  <%= link_to "Back", :back %>
@@ -1,59 +1,59 @@
1
1
  # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
2
 
3
3
  en:
4
+ devise:
5
+ confirmations:
6
+ confirmed: "Your account was successfully confirmed. You are now signed in."
7
+ send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
8
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
9
+ failure:
10
+ already_authenticated: "You are already signed in."
11
+ inactive: "Your account was not activated yet."
12
+ invalid: "Invalid email or password."
13
+ invalid_token: "Invalid authentication token."
14
+ locked: "Your account is locked."
15
+ not_found_in_database: "Invalid email or password."
16
+ timeout: "Your session expired, please sign in again to continue."
17
+ unauthenticated: "You need to sign in or sign up before continuing."
18
+ unconfirmed: "You have to confirm your account before continuing."
19
+ mailer:
20
+ confirmation_instructions:
21
+ subject: "Confirmation instructions"
22
+ reset_password_instructions:
23
+ subject: "Reset password instructions"
24
+ unlock_instructions:
25
+ subject: "Unlock Instructions"
26
+ omniauth_callbacks:
27
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
28
+ success: "Successfully authenticated from %{kind} account."
29
+ passwords:
30
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
31
+ send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
32
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
+ updated: "Your password was changed successfully. You are now signed in."
34
+ updated_not_active: "Your password was changed successfully."
35
+ registrations:
36
+ destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
37
+ signed_up: "Welcome! You have signed up successfully."
38
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
39
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
40
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
41
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
42
+ updated: "You updated your account successfully."
43
+ sessions:
44
+ signed_in: "Signed in successfully."
45
+ signed_out: "Signed out successfully."
46
+ unlocks:
47
+ send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
48
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
49
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
4
50
  errors:
5
51
  messages:
52
+ already_confirmed: "was already confirmed, please try signing in"
53
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
6
54
  expired: "has expired, please request a new one"
7
55
  not_found: "not found"
8
- already_confirmed: "was already confirmed, please try signing in"
9
56
  not_locked: "was not locked"
10
57
  not_saved:
11
58
  one: "1 error prohibited this %{resource} from being saved:"
12
59
  other: "%{count} errors prohibited this %{resource} from being saved:"
13
- confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
14
-
15
- devise:
16
- failure:
17
- already_authenticated: 'You are already signed in.'
18
- unauthenticated: 'You need to sign in or sign up before continuing.'
19
- unconfirmed: 'You have to confirm your account before continuing.'
20
- locked: 'Your account is locked.'
21
- invalid: 'Invalid email or password.'
22
- invalid_token: 'Invalid authentication token.'
23
- timeout: 'Your session expired, please sign in again to continue.'
24
- inactive: 'Your account was not activated yet.'
25
- sessions:
26
- signed_in: 'Signed in successfully.'
27
- signed_out: 'Signed out successfully.'
28
- passwords:
29
- send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
30
- updated: 'Your password was changed successfully. You are now signed in.'
31
- updated_not_active: 'Your password was changed successfully.'
32
- send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
33
- no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
34
- confirmations:
35
- send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
36
- send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
37
- confirmed: 'Your account was successfully confirmed. You are now signed in.'
38
- registrations:
39
- signed_up: 'Welcome! You have signed up successfully.'
40
- signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
41
- signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
42
- signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
43
- updated: 'You updated your account successfully.'
44
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
45
- destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
46
- unlocks:
47
- send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
48
- unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
49
- send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
50
- omniauth_callbacks:
51
- success: 'Successfully authenticated from %{kind} account.'
52
- failure: 'Could not authenticate you from %{kind} because "%{reason}".'
53
- mailer:
54
- confirmation_instructions:
55
- subject: 'Confirmation instructions'
56
- reset_password_instructions:
57
- subject: 'Reset password instructions'
58
- unlock_instructions:
59
- subject: 'Unlock Instructions'