devise 4.5.0 → 4.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +96 -4
  3. data/MIT-LICENSE +2 -1
  4. data/README.md +93 -56
  5. data/app/controllers/devise/passwords_controller.rb +1 -0
  6. data/app/controllers/devise/registrations_controller.rb +25 -7
  7. data/app/controllers/devise_controller.rb +2 -2
  8. data/app/helpers/devise_helper.rb +21 -18
  9. data/app/mailers/devise/mailer.rb +5 -5
  10. data/app/views/devise/confirmations/new.html.erb +1 -1
  11. data/app/views/devise/passwords/edit.html.erb +2 -2
  12. data/app/views/devise/passwords/new.html.erb +1 -1
  13. data/app/views/devise/registrations/edit.html.erb +1 -1
  14. data/app/views/devise/registrations/new.html.erb +1 -1
  15. data/app/views/devise/sessions/new.html.erb +2 -2
  16. data/app/views/devise/shared/_error_messages.html.erb +15 -0
  17. data/app/views/devise/shared/_links.html.erb +8 -8
  18. data/app/views/devise/unlocks/new.html.erb +1 -1
  19. data/config/locales/en.yml +3 -2
  20. data/lib/devise/controllers/helpers.rb +8 -8
  21. data/lib/devise/controllers/sign_in_out.rb +6 -4
  22. data/lib/devise/controllers/url_helpers.rb +1 -1
  23. data/lib/devise/failure_app.rb +23 -5
  24. data/lib/devise/hooks/lockable.rb +2 -5
  25. data/lib/devise/hooks/timeoutable.rb +2 -2
  26. data/lib/devise/mapping.rb +1 -1
  27. data/lib/devise/models/authenticatable.rb +20 -24
  28. data/lib/devise/models/confirmable.rb +18 -3
  29. data/lib/devise/models/database_authenticatable.rb +44 -6
  30. data/lib/devise/models/lockable.rb +12 -4
  31. data/lib/devise/models/omniauthable.rb +2 -2
  32. data/lib/devise/models/recoverable.rb +3 -3
  33. data/lib/devise/models/registerable.rb +2 -0
  34. data/lib/devise/models/rememberable.rb +2 -2
  35. data/lib/devise/models/timeoutable.rb +1 -1
  36. data/lib/devise/models/trackable.rb +1 -1
  37. data/lib/devise/models/validatable.rb +2 -2
  38. data/lib/devise/omniauth.rb +2 -5
  39. data/lib/devise/rails/deprecated_constant_accessor.rb +39 -0
  40. data/lib/devise/rails/routes.rb +6 -6
  41. data/lib/devise/strategies/authenticatable.rb +1 -1
  42. data/lib/devise/strategies/database_authenticatable.rb +3 -0
  43. data/lib/devise/test/controller_helpers.rb +4 -2
  44. data/lib/devise/test/integration_helpers.rb +1 -1
  45. data/lib/devise/version.rb +1 -1
  46. data/lib/devise.rb +14 -6
  47. data/lib/generators/active_record/devise_generator.rb +21 -6
  48. data/lib/generators/devise/controllers_generator.rb +1 -1
  49. data/lib/generators/devise/devise_generator.rb +1 -1
  50. data/lib/generators/devise/install_generator.rb +1 -5
  51. data/lib/generators/devise/views_generator.rb +1 -1
  52. data/lib/generators/templates/README +9 -1
  53. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  54. data/lib/generators/templates/devise.rb +27 -6
  55. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -1
  56. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +1 -1
  57. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
  58. metadata +18 -318
  59. data/.gitignore +0 -10
  60. data/.travis.yml +0 -69
  61. data/.yardopts +0 -9
  62. data/CODE_OF_CONDUCT.md +0 -22
  63. data/CONTRIBUTING.md +0 -79
  64. data/Gemfile +0 -39
  65. data/Gemfile.lock +0 -202
  66. data/ISSUE_TEMPLATE.md +0 -19
  67. data/Rakefile +0 -37
  68. data/bin/test +0 -13
  69. data/devise.gemspec +0 -28
  70. data/devise.png +0 -0
  71. data/gemfiles/Gemfile.rails-4.1-stable +0 -32
  72. data/gemfiles/Gemfile.rails-4.1-stable.lock +0 -171
  73. data/gemfiles/Gemfile.rails-4.2-stable +0 -32
  74. data/gemfiles/Gemfile.rails-4.2-stable.lock +0 -192
  75. data/gemfiles/Gemfile.rails-5.0-stable +0 -33
  76. data/gemfiles/Gemfile.rails-5.0-stable.lock +0 -192
  77. data/gemfiles/Gemfile.rails-5.2-rc1 +0 -26
  78. data/gemfiles/Gemfile.rails-5.2-rc1.lock +0 -201
  79. data/guides/bug_report_templates/integration_test.rb +0 -106
  80. data/test/controllers/custom_registrations_controller_test.rb +0 -42
  81. data/test/controllers/custom_strategy_test.rb +0 -66
  82. data/test/controllers/helper_methods_test.rb +0 -24
  83. data/test/controllers/helpers_test.rb +0 -318
  84. data/test/controllers/inherited_controller_i18n_messages_test.rb +0 -53
  85. data/test/controllers/internal_helpers_test.rb +0 -129
  86. data/test/controllers/load_hooks_controller_test.rb +0 -21
  87. data/test/controllers/passwords_controller_test.rb +0 -34
  88. data/test/controllers/sessions_controller_test.rb +0 -108
  89. data/test/controllers/url_helpers_test.rb +0 -67
  90. data/test/delegator_test.rb +0 -21
  91. data/test/devise_test.rb +0 -109
  92. data/test/failure_app_test.rb +0 -346
  93. data/test/generators/active_record_generator_test.rb +0 -130
  94. data/test/generators/controllers_generator_test.rb +0 -50
  95. data/test/generators/devise_generator_test.rb +0 -41
  96. data/test/generators/install_generator_test.rb +0 -26
  97. data/test/generators/mongoid_generator_test.rb +0 -25
  98. data/test/generators/views_generator_test.rb +0 -105
  99. data/test/helpers/devise_helper_test.rb +0 -51
  100. data/test/integration/authenticatable_test.rb +0 -706
  101. data/test/integration/confirmable_test.rb +0 -326
  102. data/test/integration/database_authenticatable_test.rb +0 -110
  103. data/test/integration/http_authenticatable_test.rb +0 -114
  104. data/test/integration/lockable_test.rb +0 -242
  105. data/test/integration/mounted_engine_test.rb +0 -38
  106. data/test/integration/omniauthable_test.rb +0 -148
  107. data/test/integration/recoverable_test.rb +0 -349
  108. data/test/integration/registerable_test.rb +0 -365
  109. data/test/integration/rememberable_test.rb +0 -219
  110. data/test/integration/timeoutable_test.rb +0 -186
  111. data/test/integration/trackable_test.rb +0 -99
  112. data/test/mailers/confirmation_instructions_test.rb +0 -117
  113. data/test/mailers/email_changed_test.rb +0 -132
  114. data/test/mailers/mailer_test.rb +0 -20
  115. data/test/mailers/reset_password_instructions_test.rb +0 -98
  116. data/test/mailers/unlock_instructions_test.rb +0 -93
  117. data/test/mapping_test.rb +0 -136
  118. data/test/models/authenticatable_test.rb +0 -25
  119. data/test/models/confirmable_test.rb +0 -549
  120. data/test/models/database_authenticatable_test.rb +0 -290
  121. data/test/models/lockable_test.rb +0 -352
  122. data/test/models/omniauthable_test.rb +0 -9
  123. data/test/models/recoverable_test.rb +0 -263
  124. data/test/models/registerable_test.rb +0 -9
  125. data/test/models/rememberable_test.rb +0 -184
  126. data/test/models/serializable_test.rb +0 -60
  127. data/test/models/timeoutable_test.rb +0 -53
  128. data/test/models/trackable_test.rb +0 -80
  129. data/test/models/validatable_test.rb +0 -121
  130. data/test/models_test.rb +0 -155
  131. data/test/omniauth/config_test.rb +0 -61
  132. data/test/omniauth/url_helpers_test.rb +0 -53
  133. data/test/orm/active_record.rb +0 -24
  134. data/test/orm/mongoid.rb +0 -15
  135. data/test/parameter_sanitizer_test.rb +0 -105
  136. data/test/rails_app/Rakefile +0 -6
  137. data/test/rails_app/app/active_record/admin.rb +0 -8
  138. data/test/rails_app/app/active_record/shim.rb +0 -4
  139. data/test/rails_app/app/active_record/user.rb +0 -20
  140. data/test/rails_app/app/active_record/user_on_engine.rb +0 -9
  141. data/test/rails_app/app/active_record/user_on_main_app.rb +0 -9
  142. data/test/rails_app/app/active_record/user_with_validations.rb +0 -12
  143. data/test/rails_app/app/active_record/user_without_email.rb +0 -10
  144. data/test/rails_app/app/controllers/admins/sessions_controller.rb +0 -8
  145. data/test/rails_app/app/controllers/admins_controller.rb +0 -8
  146. data/test/rails_app/app/controllers/application_controller.rb +0 -13
  147. data/test/rails_app/app/controllers/application_with_fake_engine.rb +0 -32
  148. data/test/rails_app/app/controllers/custom/registrations_controller.rb +0 -33
  149. data/test/rails_app/app/controllers/home_controller.rb +0 -31
  150. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +0 -4
  151. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +0 -4
  152. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +0 -16
  153. data/test/rails_app/app/controllers/users_controller.rb +0 -33
  154. data/test/rails_app/app/helpers/application_helper.rb +0 -5
  155. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +0 -5
  156. data/test/rails_app/app/mailers/users/mailer.rb +0 -5
  157. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +0 -6
  158. data/test/rails_app/app/mongoid/admin.rb +0 -31
  159. data/test/rails_app/app/mongoid/shim.rb +0 -25
  160. data/test/rails_app/app/mongoid/user.rb +0 -50
  161. data/test/rails_app/app/mongoid/user_on_engine.rb +0 -41
  162. data/test/rails_app/app/mongoid/user_on_main_app.rb +0 -41
  163. data/test/rails_app/app/mongoid/user_with_validations.rb +0 -37
  164. data/test/rails_app/app/mongoid/user_without_email.rb +0 -35
  165. data/test/rails_app/app/views/admins/index.html.erb +0 -1
  166. data/test/rails_app/app/views/admins/sessions/new.html.erb +0 -2
  167. data/test/rails_app/app/views/home/admin_dashboard.html.erb +0 -1
  168. data/test/rails_app/app/views/home/index.html.erb +0 -1
  169. data/test/rails_app/app/views/home/join.html.erb +0 -1
  170. data/test/rails_app/app/views/home/private.html.erb +0 -1
  171. data/test/rails_app/app/views/home/user_dashboard.html.erb +0 -1
  172. data/test/rails_app/app/views/layouts/application.html.erb +0 -24
  173. data/test/rails_app/app/views/users/edit_form.html.erb +0 -1
  174. data/test/rails_app/app/views/users/index.html.erb +0 -1
  175. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +0 -1
  176. data/test/rails_app/app/views/users/sessions/new.html.erb +0 -1
  177. data/test/rails_app/bin/bundle +0 -3
  178. data/test/rails_app/bin/rails +0 -4
  179. data/test/rails_app/bin/rake +0 -4
  180. data/test/rails_app/config/application.rb +0 -48
  181. data/test/rails_app/config/boot.rb +0 -27
  182. data/test/rails_app/config/database.yml +0 -18
  183. data/test/rails_app/config/environment.rb +0 -7
  184. data/test/rails_app/config/environments/development.rb +0 -32
  185. data/test/rails_app/config/environments/production.rb +0 -88
  186. data/test/rails_app/config/environments/test.rb +0 -47
  187. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -9
  188. data/test/rails_app/config/initializers/devise.rb +0 -187
  189. data/test/rails_app/config/initializers/inflections.rb +0 -4
  190. data/test/rails_app/config/initializers/secret_token.rb +0 -5
  191. data/test/rails_app/config/initializers/session_store.rb +0 -3
  192. data/test/rails_app/config/routes.rb +0 -128
  193. data/test/rails_app/config.ru +0 -4
  194. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -77
  195. data/test/rails_app/db/schema.rb +0 -57
  196. data/test/rails_app/lib/lazy_load_test_module.rb +0 -5
  197. data/test/rails_app/lib/shared_admin.rb +0 -23
  198. data/test/rails_app/lib/shared_user.rb +0 -32
  199. data/test/rails_app/lib/shared_user_without_email.rb +0 -28
  200. data/test/rails_app/lib/shared_user_without_omniauth.rb +0 -15
  201. data/test/rails_app/public/404.html +0 -26
  202. data/test/rails_app/public/422.html +0 -26
  203. data/test/rails_app/public/500.html +0 -26
  204. data/test/rails_app/public/favicon.ico +0 -0
  205. data/test/rails_test.rb +0 -11
  206. data/test/routes_test.rb +0 -281
  207. data/test/secret_key_finder_test.rb +0 -121
  208. data/test/support/action_controller/record_identifier.rb +0 -12
  209. data/test/support/assertions.rb +0 -30
  210. data/test/support/helpers.rb +0 -83
  211. data/test/support/http_method_compatibility.rb +0 -53
  212. data/test/support/integration.rb +0 -95
  213. data/test/support/locale/en.yml +0 -8
  214. data/test/support/mongoid.yml +0 -6
  215. data/test/support/webrat/integrations/rails.rb +0 -35
  216. data/test/test/controller_helpers_test.rb +0 -193
  217. data/test/test/integration_helpers_test.rb +0 -34
  218. data/test/test_helper.rb +0 -36
  219. data/test/test_models.rb +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4dc3a8679abb65b4043adcff5725822be38a9bfd7e686ac8c75b72ea2a705d12
4
- data.tar.gz: de207546fe24041c7986acbe23ad9f672ff1086a71ed8e6b749b6c3e648097ab
3
+ metadata.gz: 073edbd8314be8f7b4da9e8f1b2eb07f4f25faf77a4400b6ef91f6a7d6905fda
4
+ data.tar.gz: 96ba453ccdf7f73d76c40525644d867fe8a699efa7f0b3ab58f5e520af44f0d7
5
5
  SHA512:
6
- metadata.gz: fc02654fdc90c761e56a0aac94eebcadf605c92bfaf57821c305dd73f76ac7670a3da408ee757dba5726b25911c391d28df940cd76e098b4b8e370785d9749f5
7
- data.tar.gz: 28f0415a206541711baa0b0d23e718e13d12e22f712eae84309ddf2f9b76feace59ffbc6fdacd70f48e4bcb8c574492d076105154a4ab4f47f9be3e33e58d69b
6
+ metadata.gz: 3e86e75d88256721b32dc38b9ace70d25ccbdff76885c4a942452da0d01a92f7179c4e4800c55f91a1f535e4a9ecf9cce696523651b94aa4f5ee75b0016c4132
7
+ data.tar.gz: 2a42ad0db913c2aa1ae782a06edd48096b0b3bd4dbe47a243cce6a7f923663240ca3e8ad9459aa0148623fa366fa89d3a30959b1bd2e7b399343ebc207beb7bf
data/CHANGELOG.md CHANGED
@@ -1,4 +1,96 @@
1
- ### Unreleased
1
+ ### 4.8.1
2
+
3
+ * enhancements
4
+ * Add support for Rails 7.0. Please note that Turbo integration is not fully supported by Devise yet.
5
+
6
+ ### 4.8.0 - 2021-04-29
7
+
8
+ * enhancements
9
+ * Devise now enables the upgrade of OmniAuth 2+. Previously Devise would raise an error if you'd try to upgrade. Please note that OmniAuth 2 is considered a security upgrade and recommended to everyone. You can read more about the details (and possible necessary changes to your app as part of the upgrade) in [their release notes](https://github.com/omniauth/omniauth/releases/tag/v2.0.0). [Devise's OmniAuth Overview wiki](https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview) was also updated to cover OmniAuth 2.0 requirements.
10
+ - Note that the upgrade required Devise shared links that initiate the OmniAuth flow to be changed to `method: :post`, which is now a requirement for OmniAuth, part of the security improvement. If you have copied and customized the Devise shared links partial to your app, or if you have other links in your app that initiate the OmniAuth flow, they will have to be updated to use `method: :post`, or changed to use buttons (e.g. `button_to`) to work with OmniAuth 2. (if you're using links with `method: :post`, make sure your app has `rails-ujs` or `jquery-ujs` included in order for these links to work properly.)
11
+ - As part of the OmniAuth 2.0 upgrade you might also need to add the [`omniauth-rails_csrf_protection`](https://github.com/cookpad/omniauth-rails_csrf_protection) gem to your app if you don't have it already. (and you don't want to roll your own code to verify requests.) Check the OmniAuth v2 release notes for more info.
12
+ * Introduce `Lockable#reset_failed_attempts!` model method to reset failed attempts counter to 0 after the user signs in.
13
+ - This logic existed inside the lockable warden hook and is triggered automatically after the user signs in. The new model method is an extraction to allow you to override it in the application to implement things like switching to a write database if you're using the new multi-DB infrastructure from Rails for example, similar to how it's already possible with `Trackable#update_tracked_fields!`.
14
+ * Add support for Ruby 3.
15
+ * Add support for Rails 6.1.
16
+ * Move CI to GitHub Actions.
17
+
18
+ * deprecations
19
+ * `Devise::Models::Authenticatable::BLACKLIST_FOR_SERIALIZATION` is deprecated in favor of `Devise::Models::Authenticatable::UNSAFE_ATTRIBUTES_FOR_SERIALIZATION` (@hanachin)
20
+
21
+ ### 4.7.3 - 2020-09-20
22
+
23
+ * bug fixes
24
+ * Do not modify `:except` option given to `#serializable_hash`. (by @dpep)
25
+ * Fix thor deprecation when running the devise generator. (by @deivid-rodriguez)
26
+ * Fix hanging tests for streaming controllers using Devise. (by @afn)
27
+
28
+ ### 4.7.2 - 2020-06-10
29
+
30
+ * enhancements
31
+ * Increase default stretches to 12 (by @sergey-alekseev)
32
+ * Ruby 2.7 support (kwarg warnings removed)
33
+
34
+ * bug fixes
35
+ * Generate scoped views with proper scoped errors partial (by @shobhitic)
36
+ * Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
37
+
38
+ ### 4.7.1 - 2019-09-06
39
+
40
+ * bug fixes
41
+ * Fix an edge case where records with a blank `confirmation_token` could be confirmed (by @tegon)
42
+ * Fix typo inside `update_needs_confirmation` i18n key (by @lslm)
43
+
44
+ ### 4.7.0 - 2019-08-19
45
+
46
+ * enhancements
47
+ * Support Rails 6.0
48
+ * Update CI to rails 6.0.0.beta3 (by @tunnes)
49
+ * refactor method name to be more consistent (by @saiqulhaq)
50
+ * Fix rails 6.0.rc1 email uniqueness validation deprecation warning (by @Vasfed)
51
+
52
+ * bug fixes
53
+ * Add `autocomplete="new-password"` to `password_confirmation` fields (by @ferrl)
54
+ * Fix rails_51_and_up? method for Rails 6.rc1 (by @igorkasyanchuk)
55
+
56
+ ### 4.6.2 - 2019-03-26
57
+
58
+ * bug fixes
59
+ * Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/heartcombo/devise/issues/5033#issuecomment-476386275 (by @mracos)
60
+
61
+ ### 4.6.1 - 2019-02-11
62
+
63
+ * bug fixes
64
+ * Check if `root_path` is defined with `#respond_to?` instead of `#present` (by @tegon)
65
+
66
+ ### 4.6.0 - 2019-02-07
67
+
68
+ * enhancements
69
+ * Allow to skip email and password change notifications (by @iorme1)
70
+ * Include the use of `nil` for `allow_unconfirmed_access_for` in the docs (by @joaumg)
71
+ * Ignore useless files into the `.gem` file (by @huacnlee)
72
+ * Explain the code that prevents enumeration attacks inside `Devise::Strategies::DatabaseAuthenticatable` (by @tegon)
73
+ * Refactor the `devise_error_messages!` helper to render a partial (by @prograhamer)
74
+ * Add an option (`Devise.sign_in_after_change_password`) to not automatically sign in a user after changing a password (by @knjko)
75
+
76
+ * bug fixes
77
+ * Fix missing comma in Simple Form generator (by @colinross)
78
+ * Fix error with migration generator in Rails 6 (by @oystersauce8)
79
+ * Set `encrypted_password` to `nil` when `password` is set to `nil` (by @sivagollapalli)
80
+ * Consider whether the request supports flash messages inside `Devise::Controllers::Helpers#is_flashing_format?` (by @colinross)
81
+ * Fix typo inside `Devise::Generators::ControllersGenerator` (by @kopylovvlad)
82
+ * Sanitize parameters inside `Devise::Models::Authenticatable#find_or_initialize_with_errors` (by @rlue)
83
+ * `#after_database_authentication` callback was not called after authentication on password reset (by @kanmaniselvan)
84
+ * Fix corner case when `#confirmation_period_valid?` was called at the same second as `confirmation_sent_at` was set. Mostly true for date types that only have second precisions. (by @stanhu)
85
+ * Fix unclosed `li` tag in `error_messages` partial (by @mracos)
86
+ * Fix Routes issue when devise engine is mounted in another engine on Rails versions lower than 5.1 (by @a-barbieri)
87
+ * Make `#increment_failed_attempts` concurrency safe (by @tegon)
88
+ * Apply Test Helper fix to Rails 6.0 as well as 5.x (by @matthewrudy)
89
+
90
+
91
+ * deprecations
92
+ * The second argument of `DatabaseAuthenticatable`'s `#update_with_password` and `#update_without_password` is deprecated and will be removed in the next major version. It was added to support a feature deprecated in Rails 4, so you can safely remove it from your code. (by @ihatov08)
93
+ * The `DeviseHelper.devise_error_messages!` is deprecated and will be removed in the next major version. Use the `devise/shared/error_messages` partial instead. (by @mracos)
2
94
 
3
95
  ### 4.5.0 - 2018-08-15
4
96
 
@@ -11,7 +103,7 @@
11
103
  * Add `autocomplete="new-password"` to new password fields (by @gssbzn)
12
104
  * Add `autocomplete="current-password"` to current password fields (by @gssbzn)
13
105
  * Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
14
- * Update `simple_form` templates with changes from https://github.com/plataformatec/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/plataformatec/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
106
+ * Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
15
107
  * Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
16
108
 
17
109
  * bug fixes
@@ -255,8 +347,8 @@ configured (by @joshpencheon)
255
347
  end
256
348
  ```
257
349
 
258
- You can check more examples and explanations on the [README section](/plataformatec/devise#strong-parameters)
350
+ You can check more examples and explanations on the [README section](README.md#strong-parameters)
259
351
  and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
260
352
 
261
- Please check [3-stable](https://github.com/plataformatec/devise/blob/3-stable/CHANGELOG.md)
353
+ Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
262
354
  for previous changes.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2009-2017 Plataformatec. http://plataformatec.com.br
1
+ Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva.
2
+ Copyright 2009-2019 Plataformatec.
2
3
 
3
4
  Permission is hereby granted, free of charge, to any person obtaining
4
5
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,6 @@
1
- ![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
1
+ ![Devise Logo](https://raw.github.com/heartcombo/devise/master/devise.png)
2
2
 
3
- By [Plataformatec](http://plataformatec.com.br/).
4
-
5
- [![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
6
- [![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
7
-
8
- This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
3
+ [![Code Climate](https://codeclimate.com/github/heartcombo/devise.svg)](https://codeclimate.com/github/heartcombo/devise)
9
4
 
10
5
  Devise is a flexible authentication solution for Rails based on Warden. It:
11
6
 
@@ -16,16 +11,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
16
11
 
17
12
  It's composed of 10 modules:
18
13
 
19
- * [Database Authenticatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
20
- * [Omniauthable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
21
- * [Confirmable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
22
- * [Recoverable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
23
- * [Registerable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
24
- * [Rememberable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
25
- * [Trackable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
26
- * [Timeoutable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
27
- * [Validatable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
28
- * [Lockable](http://www.rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
14
+ * [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/DatabaseAuthenticatable): hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
15
+ * [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
16
+ * [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
17
+ * [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
18
+ * [Registerable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
19
+ * [Rememberable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
20
+ * [Trackable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
21
+ * [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
22
+ * [Validatable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
23
+ * [Lockable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
29
24
 
30
25
  ## Table of Contents
31
26
 
@@ -56,8 +51,8 @@ It's composed of 10 modules:
56
51
  - [ActiveJob Integration](#activejob-integration)
57
52
  - [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
58
53
  - [Other ORMs](#other-orms)
54
+ - [Rails API mode](#rails-api-mode)
59
55
  - [Additional information](#additional-information)
60
- - [Heroku](#heroku)
61
56
  - [Warden](#warden)
62
57
  - [Contributors](#contributors)
63
58
  - [License](#license)
@@ -72,15 +67,15 @@ It's composed of 10 modules:
72
67
 
73
68
  The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
74
69
 
75
- https://github.com/plataformatec/devise/wiki
70
+ https://github.com/heartcombo/devise/wiki
76
71
 
77
72
  ### Bug reports
78
73
 
79
74
  If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
80
75
 
81
- https://github.com/plataformatec/devise/wiki/Bug-reports
76
+ https://github.com/heartcombo/devise/wiki/Bug-reports
82
77
 
83
- If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
78
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
84
79
 
85
80
  ### StackOverflow and Mailing List
86
81
 
@@ -96,7 +91,7 @@ https://groups.google.com/group/plataformatec-devise
96
91
 
97
92
  You can view the Devise documentation in RDoc format here:
98
93
 
99
- http://rubydoc.info/github/plataformatec/devise/master/frames
94
+ http://rubydoc.info/github/heartcombo/devise/master/frames
100
95
 
101
96
  If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
102
97
 
@@ -104,26 +99,26 @@ If you need to use Devise with previous versions of Rails, you can always run "g
104
99
 
105
100
  There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
106
101
 
107
- https://github.com/plataformatec/devise/wiki/Example-Applications
102
+ https://github.com/heartcombo/devise/wiki/Example-Applications
108
103
 
109
104
  ### Extensions
110
105
 
111
106
  Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
112
107
 
113
- https://github.com/plataformatec/devise/wiki/Extensions
108
+ https://github.com/heartcombo/devise/wiki/Extensions
114
109
 
115
110
  ### Contributing
116
111
 
117
112
  We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
118
113
 
119
- https://github.com/plataformatec/devise/wiki/Contributing
114
+ https://github.com/heartcombo/devise/wiki/Contributing
120
115
 
121
116
  You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
122
117
  Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
123
118
 
124
119
  ### DEVISE_ORM
125
- Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
126
- The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
120
+ Since Devise supports both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
121
+ The default value of `DEVISE_ORM` is `active_record`. To run the tests for Mongoid, you can pass `mongoid`:
127
122
  ```
128
123
  DEVISE_ORM=mongoid bin/test
129
124
 
@@ -135,7 +130,7 @@ Please note that the command output will show the variable value being used.
135
130
 
136
131
  ### BUNDLE_GEMFILE
137
132
  We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
138
- Inside the [gemfiles](https://github.com/plataformatec/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
133
+ Inside the [gemfiles](https://github.com/heartcombo/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
139
134
  For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
140
135
  ```bash
141
136
  rbenv shell 2.4.2 # or rvm use 2.4.2
@@ -149,13 +144,31 @@ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
149
144
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
150
145
  ```
151
146
 
147
+ ### Running tests
148
+ Devise uses [Mini Test](https://github.com/seattlerb/minitest) as test framework.
149
+
150
+ * Running all tests:
151
+ ```bash
152
+ bin/test
153
+ ```
154
+
155
+ * Running tests for an specific file:
156
+ ```bash
157
+ bin/test test/models/trackable_test.rb
158
+ ```
159
+
160
+ * Running a specific test given a regex:
161
+ ```bash
162
+ bin/test test/models/trackable_test.rb:16
163
+ ```
164
+
152
165
  ## Starting with Rails?
153
166
 
154
- 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:
167
+ 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. Here's a few resources that should help you get started:
155
168
 
156
169
  * Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
157
- * Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
158
- * Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
170
+ * Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
171
+ * Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
159
172
 
160
173
  Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
161
174
 
@@ -251,16 +264,16 @@ member_session
251
264
  The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
252
265
 
253
266
  ```ruby
254
- devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
267
+ devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
255
268
  ```
256
269
 
257
270
  Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
258
271
 
259
272
  ### Strong Parameters
260
273
 
261
- ![The Parameter Sanitizer API has changed for Devise 4](http://messages.hellobits.com/warning.svg?message=The%20Parameter%20Sanitizer%20API%20has%20changed%20for%20Devise%204)
274
+ The Parameter Sanitizer API has changed for Devise 4 :warning:
262
275
 
263
- *For previous Devise versions see https://github.com/plataformatec/devise/tree/3-stable#strong-parameters*
276
+ *For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
264
277
 
265
278
  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.
266
279
 
@@ -270,7 +283,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
270
283
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
271
284
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
272
285
 
273
- In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
286
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
274
287
 
275
288
  ```ruby
276
289
  class ApplicationController < ActionController::Base
@@ -298,7 +311,7 @@ class ApplicationController < ActionController::Base
298
311
  end
299
312
  ```
300
313
 
301
- Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
314
+ Devise allows you to completely change Devise defaults or invoke custom behavior by passing a block:
302
315
 
303
316
  To permit simple scalar values for username and email, use this
304
317
 
@@ -421,7 +434,7 @@ If the customization at the views level is not enough, you can customize each co
421
434
  end
422
435
  ```
423
436
 
424
- Or you can simply add new behaviour to it:
437
+ Or you can simply add new behavior to it:
425
438
 
426
439
  ```ruby
427
440
  class Users::SessionsController < Devise::SessionsController
@@ -445,7 +458,7 @@ Devise also ships with default routes. If you need to customize them, you should
445
458
  devise_for :users, path: 'auth', path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
446
459
  ```
447
460
 
448
- Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/plataformatec/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
461
+ Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
449
462
 
450
463
  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:
451
464
 
@@ -501,7 +514,7 @@ en:
501
514
 
502
515
  Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
503
516
 
504
- https://github.com/plataformatec/devise/wiki/I18n
517
+ https://github.com/heartcombo/devise/wiki/I18n
505
518
 
506
519
  Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
507
520
 
@@ -513,15 +526,21 @@ cases/specs.
513
526
 
514
527
  ### Controller tests
515
528
 
516
- Controller tests require that you include `Devise::Test::ControllerHelpers` on
529
+ Controller tests require that you include `Devise::Test::IntegrationHelpers` on
517
530
  your test case or its parent `ActionController::TestCase` superclass.
518
- For Rails 5, include `Devise::Test::IntegrationHelpers` instead, since the superclass
519
- for controller tests has been changed to ActionDispatch::IntegrationTest
531
+ For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
532
+ for controller tests was changed to ActionDispatch::IntegrationTest
520
533
  (for more details, see the [Integration tests](#integration-tests) section).
521
534
 
522
535
  ```ruby
523
536
  class PostsControllerTest < ActionController::TestCase
524
- include Devise::Test::ControllerHelpers
537
+ include Devise::Test::IntegrationHelpers # Rails >= 5
538
+ end
539
+ ```
540
+
541
+ ```ruby
542
+ class PostsControllerTest < ActionController::TestCase
543
+ include Devise::Test::ControllerHelpers # Rails < 5
525
544
  end
526
545
  ```
527
546
 
@@ -601,7 +620,7 @@ are executed in your tests.
601
620
 
602
621
  You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
603
622
 
604
- * https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
623
+ * https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
605
624
 
606
625
  ### OmniAuth
607
626
 
@@ -613,7 +632,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
613
632
 
614
633
  You can read more about OmniAuth support in the wiki:
615
634
 
616
- * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
635
+ * https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
617
636
 
618
637
  ### Configuring multiple models
619
638
 
@@ -660,12 +679,12 @@ end
660
679
 
661
680
  ### Password reset tokens and Rails logs
662
681
 
663
- If you enable the [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
682
+ If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
664
683
 
665
684
  1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
666
685
  2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
667
686
 
668
- Rails sets the production logger level to DEBUG by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
687
+ Rails sets the production logger level to INFO by default. Consider changing your production logger level to WARN if you wish to prevent tokens from being leaked into your logs. In `config/environments/production.rb`:
669
688
 
670
689
  ```ruby
671
690
  config.log_level = :warn
@@ -676,32 +695,50 @@ config.log_level = :warn
676
695
 
677
696
  Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
678
697
 
679
- ## Additional information
698
+ ### Rails API Mode
680
699
 
681
- ### Heroku
700
+ Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). Devise is _somewhat_ able to handle applications that are built in this mode without additional modifications in the sense that it should not raise exceptions and the like. But some issues may still arise during `development`/`testing`, as we still don't know the full extent of this compatibility. (For more information, see [issue #4947](https://github.com/heartcombo/devise/issues/4947/))
682
701
 
683
- Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
702
+ #### Supported Authentication Strategies
703
+ API-only applications don't support browser-based authentication via cookies, which is devise's default. Yet, devise can still provide authentication out of the box in those cases with the `http_authenticatable` strategy, which uses HTTP Basic Auth and authenticates the user on each request. (For more info, see this wiki article for [How To: Use HTTP Basic Authentication](https://github.com/heartcombo/devise/wiki/How-To:-Use-HTTP-Basic-Authentication))
704
+
705
+ The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
684
706
 
685
707
  ```ruby
686
- config.assets.initialize_on_precompile = false
708
+ config.http_authenticatable = [:database]
687
709
  ```
688
710
 
689
- Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
711
+ This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
712
+ A common authentication strategy for APIs is token-based authentication. For more information on extending devise to support this type of authentication and others, see the wiki article for [Simple Token Authentication Examples and alternatives](https://github.com/heartcombo/devise/wiki/How-To:-Simple-Token-Authentication-Example#alternatives) or this blog post on [Custom authentication methods with Devise](http://blog.plataformatec.com.br/2019/01/custom-authentication-methods-with-devise/).
713
+
714
+ #### Testing
715
+ API Mode changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
716
+
717
+ ```ruby
718
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
719
+ Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
720
+ ```
721
+
722
+ For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
723
+
724
+ Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
725
+
726
+ ## Additional information
690
727
 
691
728
  ### Warden
692
729
 
693
730
  Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
694
731
 
695
- https://github.com/hassox/warden
732
+ https://github.com/wardencommunity/warden
696
733
 
697
734
  ### Contributors
698
735
 
699
736
  We have a long list of valued contributors. Check them all at:
700
737
 
701
- https://github.com/plataformatec/devise/graphs/contributors
738
+ https://github.com/heartcombo/devise/graphs/contributors
702
739
 
703
740
  ## License
704
741
 
705
- MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
742
+ MIT License. Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
706
743
 
707
- You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
744
+ The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
@@ -39,6 +39,7 @@ class Devise::PasswordsController < DeviseController
39
39
  if Devise.sign_in_after_reset_password
40
40
  flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
41
41
  set_flash_message!(:notice, flash_message)
42
+ resource.after_database_authentication
42
43
  sign_in(resource_name, resource)
43
44
  else
44
45
  set_flash_message!(:notice, :updated_not_active)
@@ -50,12 +50,9 @@ class Devise::RegistrationsController < DeviseController
50
50
  resource_updated = update_resource(resource, account_update_params)
51
51
  yield resource if block_given?
52
52
  if resource_updated
53
- if is_flashing_format?
54
- flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
55
- :update_needs_confirmation : :updated
56
- set_flash_message :notice, flash_key
57
- end
58
- bypass_sign_in resource, scope: resource_name
53
+ set_flash_message_for_update(resource, prev_unconfirmed_email)
54
+ bypass_sign_in resource, scope: resource_name if sign_in_after_change_password?
55
+
59
56
  respond_with resource, location: after_update_path_for(resource)
60
57
  else
61
58
  clean_up_passwords resource
@@ -127,7 +124,7 @@ class Devise::RegistrationsController < DeviseController
127
124
  # The default url to be used after updating a resource. You need to overwrite
128
125
  # this method in your own RegistrationsController.
129
126
  def after_update_path_for(resource)
130
- signed_in_root_path(resource)
127
+ sign_in_after_change_password? ? signed_in_root_path(resource) : new_session_path(resource_name)
131
128
  end
132
129
 
133
130
  # Authenticates the current scope and gets the current resource from the session.
@@ -147,4 +144,25 @@ class Devise::RegistrationsController < DeviseController
147
144
  def translation_scope
148
145
  'devise.registrations'
149
146
  end
147
+
148
+ private
149
+
150
+ def set_flash_message_for_update(resource, prev_unconfirmed_email)
151
+ return unless is_flashing_format?
152
+
153
+ flash_key = if update_needs_confirmation?(resource, prev_unconfirmed_email)
154
+ :update_needs_confirmation
155
+ elsif sign_in_after_change_password?
156
+ :updated
157
+ else
158
+ :updated_but_not_signed_in
159
+ end
160
+ set_flash_message :notice, flash_key
161
+ end
162
+
163
+ def sign_in_after_change_password?
164
+ return true if account_update_params[:password].blank?
165
+
166
+ Devise.sign_in_after_change_password
167
+ end
150
168
  end
@@ -112,7 +112,7 @@ MESSAGE
112
112
  end
113
113
 
114
114
  if authenticated && resource = warden.user(resource_name)
115
- flash[:alert] = I18n.t("devise.failure.already_authenticated")
115
+ set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')
116
116
  redirect_to after_sign_in_path_for(resource)
117
117
  end
118
118
  end
@@ -184,7 +184,7 @@ MESSAGE
184
184
  options[:default] = Array(options[:default]).unshift(kind.to_sym)
185
185
  options[:resource_name] = resource_name
186
186
  options = devise_i18n_options(options)
187
- I18n.t("#{options[:resource_name]}.#{kind}", options)
187
+ I18n.t("#{options[:resource_name]}.#{kind}", **options)
188
188
  end
189
189
 
190
190
  # Controllers inheriting DeviseController are advised to override this
@@ -1,27 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeviseHelper
4
- # A simple way to show error messages for the current devise resource. If you need
5
- # to customize this method, you can either overwrite it in your application helpers or
6
- # copy the views to your application.
7
- #
8
- # This method is intended to stay simple and it is unlikely that we are going to change
9
- # it to add more behavior or options.
4
+ # Retain this method for backwards compatibility, deprecated in favor of modifying the
5
+ # devise/shared/error_messages partial.
10
6
  def devise_error_messages!
11
- return "" if resource.errors.empty?
7
+ ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc
8
+ [Devise] `DeviseHelper#devise_error_messages!` is deprecated and will be
9
+ removed in the next major version.
10
+
11
+ Devise now uses a partial under "devise/shared/error_messages" to display
12
+ error messages by default, and make them easier to customize. Update your
13
+ views changing calls from:
14
+
15
+ <%= devise_error_messages! %>
12
16
 
13
- messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
14
- sentence = I18n.t("errors.messages.not_saved",
15
- count: resource.errors.count,
16
- resource: resource.class.model_name.human.downcase)
17
+ to:
17
18
 
18
- html = <<-HTML
19
- <div id="error_explanation">
20
- <h2>#{sentence}</h2>
21
- <ul>#{messages}</ul>
22
- </div>
23
- HTML
19
+ <%= render "devise/shared/error_messages", resource: resource %>
20
+
21
+ To start customizing how errors are displayed, you can copy the partial
22
+ from devise to your `app/views` folder. Alternatively, you can run
23
+ `rails g devise:views` which will copy all of them again to your app.
24
+ DEPRECATION
25
+
26
+ return "" if resource.errors.empty?
24
27
 
25
- html.html_safe
28
+ render "devise/shared/error_messages", resource: resource
26
29
  end
27
30
  end
@@ -4,26 +4,26 @@ if defined?(ActionMailer)
4
4
  class Devise::Mailer < Devise.parent_mailer.constantize
5
5
  include Devise::Mailers::Helpers
6
6
 
7
- def confirmation_instructions(record, token, opts={})
7
+ def confirmation_instructions(record, token, opts = {})
8
8
  @token = token
9
9
  devise_mail(record, :confirmation_instructions, opts)
10
10
  end
11
11
 
12
- def reset_password_instructions(record, token, opts={})
12
+ def reset_password_instructions(record, token, opts = {})
13
13
  @token = token
14
14
  devise_mail(record, :reset_password_instructions, opts)
15
15
  end
16
16
 
17
- def unlock_instructions(record, token, opts={})
17
+ def unlock_instructions(record, token, opts = {})
18
18
  @token = token
19
19
  devise_mail(record, :unlock_instructions, opts)
20
20
  end
21
21
 
22
- def email_changed(record, opts={})
22
+ def email_changed(record, opts = {})
23
23
  devise_mail(record, :email_changed, opts)
24
24
  end
25
25
 
26
- def password_change(record, opts={})
26
+ def password_change(record, opts = {})
27
27
  devise_mail(record, :password_change, opts)
28
28
  end
29
29
  end