devise 4.2.0 → 4.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (225) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +27 -5
  3. data/CHANGELOG.md +65 -0
  4. data/CONTRIBUTING.md +68 -28
  5. data/Gemfile +3 -1
  6. data/Gemfile.lock +79 -83
  7. data/ISSUE_TEMPLATE.md +19 -0
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +108 -11
  10. data/Rakefile +1 -0
  11. data/app/controllers/devise/confirmations_controller.rb +2 -0
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +4 -2
  13. data/app/controllers/devise/passwords_controller.rb +2 -0
  14. data/app/controllers/devise/registrations_controller.rb +6 -3
  15. data/app/controllers/devise/sessions_controller.rb +3 -1
  16. data/app/controllers/devise/unlocks_controller.rb +2 -0
  17. data/app/controllers/devise_controller.rb +2 -0
  18. data/app/helpers/devise_helper.rb +2 -0
  19. data/app/mailers/devise/mailer.rb +6 -0
  20. data/app/views/devise/confirmations/new.html.erb +1 -1
  21. data/app/views/devise/mailer/email_changed.html.erb +7 -0
  22. data/app/views/devise/passwords/new.html.erb +1 -1
  23. data/app/views/devise/registrations/edit.html.erb +1 -1
  24. data/app/views/devise/registrations/new.html.erb +1 -1
  25. data/app/views/devise/sessions/new.html.erb +1 -1
  26. data/app/views/devise/unlocks/new.html.erb +1 -1
  27. data/config/locales/en.yml +2 -0
  28. data/devise.gemspec +3 -1
  29. data/gemfiles/Gemfile.rails-4.1-stable +3 -1
  30. data/gemfiles/Gemfile.rails-4.1-stable.lock +67 -70
  31. data/gemfiles/Gemfile.rails-4.2-stable +3 -1
  32. data/gemfiles/Gemfile.rails-4.2-stable.lock +69 -73
  33. data/gemfiles/Gemfile.rails-5.0-stable +33 -0
  34. data/gemfiles/Gemfile.rails-5.0-stable.lock +192 -0
  35. data/gemfiles/Gemfile.rails-5.2-rc1 +26 -0
  36. data/gemfiles/Gemfile.rails-5.2-rc1.lock +201 -0
  37. data/guides/bug_report_templates/integration_test.rb +2 -0
  38. data/lib/devise/controllers/helpers.rb +2 -0
  39. data/lib/devise/controllers/rememberable.rb +2 -0
  40. data/lib/devise/controllers/scoped_views.rb +2 -0
  41. data/lib/devise/controllers/sign_in_out.rb +6 -1
  42. data/lib/devise/controllers/store_location.rb +25 -7
  43. data/lib/devise/controllers/url_helpers.rb +2 -0
  44. data/lib/devise/delegator.rb +2 -0
  45. data/lib/devise/encryptor.rb +2 -0
  46. data/lib/devise/failure_app.rb +14 -12
  47. data/lib/devise/hooks/activatable.rb +2 -0
  48. data/lib/devise/hooks/csrf_cleaner.rb +2 -0
  49. data/lib/devise/hooks/forgetable.rb +2 -0
  50. data/lib/devise/hooks/lockable.rb +6 -1
  51. data/lib/devise/hooks/proxy.rb +2 -0
  52. data/lib/devise/hooks/rememberable.rb +2 -0
  53. data/lib/devise/hooks/timeoutable.rb +2 -0
  54. data/lib/devise/hooks/trackable.rb +2 -0
  55. data/lib/devise/mailers/helpers.rb +6 -3
  56. data/lib/devise/mapping.rb +2 -0
  57. data/lib/devise/models/authenticatable.rb +4 -2
  58. data/lib/devise/models/confirmable.rb +53 -17
  59. data/lib/devise/models/database_authenticatable.rb +40 -4
  60. data/lib/devise/models/lockable.rb +8 -2
  61. data/lib/devise/models/omniauthable.rb +2 -0
  62. data/lib/devise/models/recoverable.rb +26 -9
  63. data/lib/devise/models/registerable.rb +2 -0
  64. data/lib/devise/models/rememberable.rb +4 -2
  65. data/lib/devise/models/timeoutable.rb +2 -0
  66. data/lib/devise/models/trackable.rb +7 -0
  67. data/lib/devise/models/validatable.rb +10 -3
  68. data/lib/devise/models.rb +3 -1
  69. data/lib/devise/modules.rb +2 -0
  70. data/lib/devise/omniauth/config.rb +2 -0
  71. data/lib/devise/omniauth/url_helpers.rb +2 -0
  72. data/lib/devise/omniauth.rb +2 -0
  73. data/lib/devise/orm/active_record.rb +2 -0
  74. data/lib/devise/orm/mongoid.rb +2 -0
  75. data/lib/devise/parameter_filter.rb +2 -0
  76. data/lib/devise/parameter_sanitizer.rb +2 -0
  77. data/lib/devise/rails/routes.rb +3 -1
  78. data/lib/devise/rails/warden_compat.rb +2 -0
  79. data/lib/devise/rails.rb +3 -5
  80. data/lib/devise/secret_key_finder.rb +25 -0
  81. data/lib/devise/strategies/authenticatable.rb +2 -0
  82. data/lib/devise/strategies/base.rb +2 -0
  83. data/lib/devise/strategies/database_authenticatable.rb +2 -0
  84. data/lib/devise/strategies/rememberable.rb +2 -0
  85. data/lib/devise/test/controller_helpers.rb +4 -1
  86. data/lib/devise/test/integration_helpers.rb +2 -0
  87. data/lib/devise/test_helpers.rb +3 -1
  88. data/lib/devise/time_inflector.rb +2 -0
  89. data/lib/devise/token_generator.rb +2 -0
  90. data/lib/devise/version.rb +3 -1
  91. data/lib/devise.rb +17 -2
  92. data/lib/generators/active_record/devise_generator.rb +15 -2
  93. data/lib/generators/active_record/templates/migration.rb +3 -1
  94. data/lib/generators/active_record/templates/migration_existing.rb +2 -0
  95. data/lib/generators/devise/controllers_generator.rb +2 -0
  96. data/lib/generators/devise/devise_generator.rb +4 -2
  97. data/lib/generators/devise/install_generator.rb +2 -0
  98. data/lib/generators/devise/orm_helpers.rb +7 -1
  99. data/lib/generators/devise/views_generator.rb +7 -8
  100. data/lib/generators/mongoid/devise_generator.rb +2 -0
  101. data/lib/generators/templates/controllers/confirmations_controller.rb +2 -0
  102. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +2 -0
  103. data/lib/generators/templates/controllers/passwords_controller.rb +2 -0
  104. data/lib/generators/templates/controllers/registrations_controller.rb +4 -2
  105. data/lib/generators/templates/controllers/sessions_controller.rb +3 -1
  106. data/lib/generators/templates/controllers/unlocks_controller.rb +2 -0
  107. data/lib/generators/templates/devise.rb +10 -1
  108. data/lib/generators/templates/markerb/email_changed.markerb +7 -0
  109. data/lib/generators/templates/markerb/password_change.markerb +2 -2
  110. data/test/controllers/custom_registrations_controller_test.rb +2 -0
  111. data/test/controllers/custom_strategy_test.rb +2 -0
  112. data/test/controllers/helper_methods_test.rb +2 -0
  113. data/test/controllers/helpers_test.rb +5 -3
  114. data/test/controllers/inherited_controller_i18n_messages_test.rb +2 -0
  115. data/test/controllers/internal_helpers_test.rb +2 -0
  116. data/test/controllers/load_hooks_controller_test.rb +2 -0
  117. data/test/controllers/passwords_controller_test.rb +2 -0
  118. data/test/controllers/sessions_controller_test.rb +2 -0
  119. data/test/controllers/url_helpers_test.rb +2 -0
  120. data/test/delegator_test.rb +2 -0
  121. data/test/devise_test.rb +2 -0
  122. data/test/failure_app_test.rb +2 -0
  123. data/test/generators/active_record_generator_test.rb +47 -0
  124. data/test/generators/controllers_generator_test.rb +2 -0
  125. data/test/generators/devise_generator_test.rb +2 -0
  126. data/test/generators/install_generator_test.rb +2 -0
  127. data/test/generators/mongoid_generator_test.rb +2 -0
  128. data/test/generators/views_generator_test.rb +2 -0
  129. data/test/helpers/devise_helper_test.rb +2 -0
  130. data/test/integration/authenticatable_test.rb +10 -2
  131. data/test/integration/confirmable_test.rb +2 -0
  132. data/test/integration/database_authenticatable_test.rb +2 -0
  133. data/test/integration/http_authenticatable_test.rb +8 -0
  134. data/test/integration/lockable_test.rb +5 -3
  135. data/test/integration/mounted_engine_test.rb +2 -0
  136. data/test/integration/omniauthable_test.rb +13 -0
  137. data/test/integration/recoverable_test.rb +2 -0
  138. data/test/integration/registerable_test.rb +2 -0
  139. data/test/integration/rememberable_test.rb +9 -1
  140. data/test/integration/timeoutable_test.rb +2 -0
  141. data/test/integration/trackable_test.rb +7 -0
  142. data/test/mailers/confirmation_instructions_test.rb +2 -0
  143. data/test/mailers/email_changed_test.rb +132 -0
  144. data/test/mailers/mailer_test.rb +20 -0
  145. data/test/mailers/reset_password_instructions_test.rb +2 -0
  146. data/test/mailers/unlock_instructions_test.rb +2 -0
  147. data/test/mapping_test.rb +2 -0
  148. data/test/models/authenticatable_test.rb +2 -0
  149. data/test/models/confirmable_test.rb +30 -0
  150. data/test/models/database_authenticatable_test.rb +15 -1
  151. data/test/models/lockable_test.rb +2 -0
  152. data/test/models/omniauthable_test.rb +2 -0
  153. data/test/models/recoverable_test.rb +13 -1
  154. data/test/models/registerable_test.rb +2 -0
  155. data/test/models/rememberable_test.rb +2 -0
  156. data/test/models/serializable_test.rb +6 -0
  157. data/test/models/timeoutable_test.rb +2 -0
  158. data/test/models/trackable_test.rb +21 -0
  159. data/test/models/validatable_test.rb +4 -2
  160. data/test/models_test.rb +2 -0
  161. data/test/omniauth/config_test.rb +11 -7
  162. data/test/omniauth/url_helpers_test.rb +2 -0
  163. data/test/orm/active_record.rb +9 -2
  164. data/test/orm/mongoid.rb +3 -1
  165. data/test/parameter_sanitizer_test.rb +2 -0
  166. data/test/rails_app/app/active_record/admin.rb +2 -0
  167. data/test/rails_app/app/active_record/shim.rb +2 -0
  168. data/test/rails_app/app/active_record/user.rb +14 -1
  169. data/test/rails_app/app/active_record/user_on_engine.rb +2 -0
  170. data/test/rails_app/app/active_record/user_on_main_app.rb +2 -0
  171. data/test/rails_app/app/active_record/user_with_validations.rb +12 -0
  172. data/test/rails_app/app/active_record/user_without_email.rb +2 -0
  173. data/test/rails_app/app/controllers/admins/sessions_controller.rb +2 -0
  174. data/test/rails_app/app/controllers/admins_controller.rb +2 -0
  175. data/test/rails_app/app/controllers/application_controller.rb +2 -0
  176. data/test/rails_app/app/controllers/application_with_fake_engine.rb +2 -0
  177. data/test/rails_app/app/controllers/custom/registrations_controller.rb +2 -0
  178. data/test/rails_app/app/controllers/home_controller.rb +3 -1
  179. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  180. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  181. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +3 -1
  182. data/test/rails_app/app/controllers/users_controller.rb +5 -3
  183. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  184. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +2 -0
  185. data/test/rails_app/app/mailers/users/mailer.rb +2 -0
  186. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +2 -0
  187. data/test/rails_app/app/mongoid/admin.rb +2 -0
  188. data/test/rails_app/app/mongoid/shim.rb +2 -0
  189. data/test/rails_app/app/mongoid/user.rb +11 -0
  190. data/test/rails_app/app/mongoid/user_on_engine.rb +2 -0
  191. data/test/rails_app/app/mongoid/user_on_main_app.rb +2 -0
  192. data/test/rails_app/app/mongoid/user_with_validations.rb +37 -0
  193. data/test/rails_app/app/mongoid/user_without_email.rb +2 -0
  194. data/test/rails_app/config/application.rb +6 -2
  195. data/test/rails_app/config/boot.rb +16 -3
  196. data/test/rails_app/config/environment.rb +2 -0
  197. data/test/rails_app/config/environments/development.rb +2 -0
  198. data/test/rails_app/config/environments/production.rb +2 -0
  199. data/test/rails_app/config/environments/test.rb +2 -0
  200. data/test/rails_app/config/initializers/backtrace_silencers.rb +2 -0
  201. data/test/rails_app/config/initializers/devise.rb +2 -0
  202. data/test/rails_app/config/initializers/inflections.rb +2 -0
  203. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  204. data/test/rails_app/config/initializers/session_store.rb +2 -0
  205. data/test/rails_app/config/routes.rb +2 -0
  206. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +2 -0
  207. data/test/rails_app/db/schema.rb +2 -0
  208. data/test/rails_app/lib/shared_admin.rb +7 -1
  209. data/test/rails_app/lib/shared_user.rb +2 -0
  210. data/test/rails_app/lib/shared_user_without_email.rb +2 -0
  211. data/test/rails_app/lib/shared_user_without_omniauth.rb +2 -0
  212. data/test/rails_test.rb +2 -0
  213. data/test/routes_test.rb +7 -5
  214. data/test/secret_key_finder_test.rb +97 -0
  215. data/test/support/action_controller/record_identifier.rb +2 -0
  216. data/test/support/assertions.rb +2 -0
  217. data/test/support/helpers.rb +6 -0
  218. data/test/support/http_method_compatibility.rb +2 -0
  219. data/test/support/integration.rb +3 -0
  220. data/test/support/webrat/integrations/rails.rb +2 -0
  221. data/test/test/controller_helpers_test.rb +16 -1
  222. data/test/test/integration_helpers_test.rb +2 -0
  223. data/test/test_helper.rb +2 -0
  224. data/test/test_models.rb +2 -0
  225. metadata +23 -5
data/README.md CHANGED
@@ -17,7 +17,7 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
17
17
  It's composed of 10 modules:
18
18
 
19
19
  * [Database Authenticatable](http://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://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/intridea/omniauth) support.
20
+ * [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
21
21
  * [Confirmable](http://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
22
  * [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
23
23
  * [Registerable](http://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.
@@ -27,6 +27,50 @@ It's composed of 10 modules:
27
27
  * [Validatable](http://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
28
  * [Lockable](http://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.
29
29
 
30
+ ## Table of Contents
31
+
32
+ <!-- TOC depthFrom:1 depthTo:6 withLinks:1 orderedList:0 -->
33
+
34
+ - [Information](#information)
35
+ - [The Devise wiki](#the-devise-wiki)
36
+ - [Bug reports](#bug-reports)
37
+ - [StackOverflow and Mailing List](#stackoverflow-and-mailing-list)
38
+ - [RDocs](#rdocs)
39
+ - [Example applications](#example-applications)
40
+ - [Extensions](#extensions)
41
+ - [Contributing](#contributing)
42
+ - [Starting with Rails?](#starting-with-rails)
43
+ - [Getting started](#getting-started)
44
+ - [Controller filters and helpers](#controller-filters-and-helpers)
45
+ - [Configuring Models](#configuring-models)
46
+ - [Strong Parameters](#strong-parameters)
47
+ - [Configuring views](#configuring-views)
48
+ - [Configuring controllers](#configuring-controllers)
49
+ - [Configuring routes](#configuring-routes)
50
+ - [I18n](#i18n)
51
+ - [Test helpers](#test-helpers)
52
+ - [Controller tests](#controller-tests)
53
+ - [Integration tests](#integration-tests)
54
+ - [OmniAuth](#omniauth)
55
+ - [Configuring multiple models](#configuring-multiple-models)
56
+ - [Create a migration with the required fields](#create-a-migration-with-the-required-fields)
57
+ - [Inside your Admin model](#inside-your-admin-model)
58
+ - [Inside your routes](#inside-your-routes)
59
+ - [Inside your protected controller](#inside-your-protected-controller)
60
+ - [Inside your controllers and views](#inside-your-controllers-and-views)
61
+ - [ActiveJob Integration](#activejob-integration)
62
+ - [Password reset tokens and Rails logs](#password-reset-tokens-and-rails-logs)
63
+ - [Other ORMs](#other-orms)
64
+ - [Additional information](#additional-information)
65
+ - [Heroku](#heroku)
66
+ - [Warden](#warden)
67
+ - [Contributors](#contributors)
68
+ - [License](#license)
69
+
70
+ <!-- /TOC -->
71
+
72
+
73
+
30
74
  ## Information
31
75
 
32
76
  ### The Devise wiki
@@ -43,9 +87,13 @@ https://github.com/plataformatec/devise/wiki/Bug-reports
43
87
 
44
88
  If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
45
89
 
46
- ### Mailing list
90
+ ### StackOverflow and Mailing List
91
+
92
+ If you have any questions, comments, or concerns, please use StackOverflow instead of the GitHub issue tracker:
47
93
 
48
- If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
94
+ http://stackoverflow.com/questions/tagged/devise
95
+
96
+ The deprecated mailing list can still be read on
49
97
 
50
98
  https://groups.google.com/group/plataformatec-devise
51
99
 
@@ -75,7 +123,36 @@ We hope that you will consider contributing to Devise. Please read this short ov
75
123
 
76
124
  https://github.com/plataformatec/devise/wiki/Contributing
77
125
 
78
- 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 "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
126
+ 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`.
127
+ 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`.
128
+
129
+ ### DEVISE_ORM
130
+ Since Devise support both Mongoid and ActiveRecord, we rely on this variable to run specific code for each ORM.
131
+ The default value of `DEVISE_ORM` is `active_record`. To run the tests for mongoid, you can pass `mongoid`:
132
+ ```
133
+ DEVISE_ORM=mongoid bin/test
134
+
135
+ ==> Devise.orm = :mongoid
136
+ ```
137
+ When running the tests for Mongoid, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
138
+
139
+ Please note that the command output will show the variable value being used.
140
+
141
+ ### BUNDLE_GEMFILE
142
+ We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
143
+ 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 brakes on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
144
+ For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
145
+ ```bash
146
+ rbenv shell 2.4.2 # or rvm use 2.4.2
147
+ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
148
+ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bin/test
149
+ ```
150
+
151
+ You can also combine both of them if the tests broke for Mongoid:
152
+ ```bash
153
+ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable bundle install
154
+ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.1-stable DEVISE_ORM=mongoid bin/test
155
+ ```
79
156
 
80
157
  ## Starting with Rails?
81
158
 
@@ -95,7 +172,7 @@ Devise 4.0 works with Rails 4.1 onwards. You can add it to your Gemfile with:
95
172
  gem 'devise'
96
173
  ```
97
174
 
98
- Run the bundle command to install it.
175
+ Then run `bundle install`
99
176
 
100
177
  Next, you need to run the generator:
101
178
 
@@ -120,9 +197,9 @@ $ rails generate devise MODEL
120
197
 
121
198
  Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration.
122
199
 
123
- Then run `rake db:migrate`
200
+ Then run `rails db:migrate`
124
201
 
125
- You should restart your application after changing Devise's configuration options. Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
202
+ You should restart your application after changing Devise's configuration options (this includes stopping spring). Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
126
203
 
127
204
  ### Controller filters and helpers
128
205
 
@@ -179,7 +256,7 @@ member_session
179
256
  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:
180
257
 
181
258
  ```ruby
182
- devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
259
+ devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 12
183
260
  ```
184
261
 
185
262
  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`.
@@ -212,7 +289,21 @@ class ApplicationController < ActionController::Base
212
289
  end
213
290
  ```
214
291
 
215
- The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
292
+ The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types:
293
+
294
+ ```ruby
295
+ class ApplicationController < ActionController::Base
296
+ before_action :configure_permitted_parameters, if: :devise_controller?
297
+
298
+ protected
299
+
300
+ def configure_permitted_parameters
301
+ devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]])
302
+ end
303
+ end
304
+ ```
305
+
306
+ Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
216
307
 
217
308
  To permit simple scalar values for username and email, use this
218
309
 
@@ -370,6 +461,12 @@ end
370
461
 
371
462
  This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
372
463
 
464
+ Please note: You will still need to add `devise_for` in your routes in order to use helper methods such as `current_user`.
465
+
466
+ ```ruby
467
+ devise_for :users, skip: :all
468
+ ```
469
+
373
470
  ### I18n
374
471
 
375
472
  Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
@@ -447,7 +544,7 @@ tests:
447
544
 
448
545
  ```ruby
449
546
  sign_in @user
450
- sign_in @user, scope: admin
547
+ sign_in @user, scope: :admin
451
548
  ```
452
549
 
453
550
  If you are testing Devise internal controllers or a controller that inherits
@@ -606,6 +703,6 @@ https://github.com/plataformatec/devise/graphs/contributors
606
703
 
607
704
  ## License
608
705
 
609
- MIT License. Copyright 2009-2016 Plataformatec. http://plataformatec.com.br
706
+ MIT License. Copyright 2009-2018 Plataformatec. http://plataformatec.com.br
610
707
 
611
708
  You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/gem_tasks'
4
5
  require 'rake/testtask'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::ConfirmationsController < DeviseController
2
4
  # GET /resource/confirmation/new
3
5
  def new
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::OmniauthCallbacksController < DeviseController
2
4
  prepend_before_action { request.env["devise.skip_timeout"] = true }
3
5
 
4
6
  def passthru
5
- render status: 404, text: "Not found. Authentication passthru."
7
+ render status: 404, plain: "Not found. Authentication passthru."
6
8
  end
7
9
 
8
10
  def failure
9
- set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
11
+ set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
10
12
  redirect_to after_omniauth_failure_path_for(resource_name)
11
13
  end
12
14
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::PasswordsController < DeviseController
2
4
  prepend_before_action :require_no_authentication
3
5
  # Render the #edit only if coming from a reset password email link
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::RegistrationsController < DeviseController
2
4
  prepend_before_action :require_no_authentication, only: [:new, :create, :cancel]
3
5
  prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy]
@@ -5,7 +7,7 @@ class Devise::RegistrationsController < DeviseController
5
7
 
6
8
  # GET /resource/sign_up
7
9
  def new
8
- build_resource({})
10
+ build_resource
9
11
  yield resource if block_given?
10
12
  respond_with resource
11
13
  end
@@ -57,6 +59,7 @@ class Devise::RegistrationsController < DeviseController
57
59
  respond_with resource, location: after_update_path_for(resource)
58
60
  else
59
61
  clean_up_passwords resource
62
+ set_minimum_password_length
60
63
  respond_with resource
61
64
  end
62
65
  end
@@ -96,8 +99,8 @@ class Devise::RegistrationsController < DeviseController
96
99
 
97
100
  # Build a devise resource passing in the session. Useful to move
98
101
  # temporary session data to the newly created user.
99
- def build_resource(hash=nil)
100
- self.resource = resource_class.new_with_session(hash || {}, session)
102
+ def build_resource(hash = {})
103
+ self.resource = resource_class.new_with_session(hash, session)
101
104
  end
102
105
 
103
106
  # Signs in a user on sign up. You can overwrite this method in your own
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::SessionsController < DeviseController
2
4
  prepend_before_action :require_no_authentication, only: [:new, :create]
3
5
  prepend_before_action :allow_params_authentication!, only: :create
4
6
  prepend_before_action :verify_signed_out_user, only: :destroy
5
- prepend_before_action only: [:create, :destroy] { request.env["devise.skip_timeout"] = true }
7
+ prepend_before_action(only: [:create, :destroy]) { request.env["devise.skip_timeout"] = true }
6
8
 
7
9
  # GET /resource/sign_in
8
10
  def new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Devise::UnlocksController < DeviseController
2
4
  prepend_before_action :require_no_authentication
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # All Devise controllers are inherited from here.
2
4
  class DeviseController < Devise.parent_controller.constantize
3
5
  include Devise::Controllers::ScopedViews
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DeviseHelper
2
4
  # A simple way to show error messages for the current devise resource. If you need
3
5
  # to customize this method, you can either overwrite it in your application helpers or
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined?(ActionMailer)
2
4
  class Devise::Mailer < Devise.parent_mailer.constantize
3
5
  include Devise::Mailers::Helpers
@@ -17,6 +19,10 @@ if defined?(ActionMailer)
17
19
  devise_mail(record, :unlock_instructions, opts)
18
20
  end
19
21
 
22
+ def email_changed(record, opts={})
23
+ devise_mail(record, :email_changed, opts)
24
+ end
25
+
20
26
  def password_change(record, opts={})
21
27
  devise_mail(record, :password_change, opts)
22
28
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="field">
7
7
  <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
8
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @email %>!</p>
2
+
3
+ <% if @resource.try(:unconfirmed_email?) %>
4
+ <p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
5
+ <% else %>
6
+ <p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
7
+ <% end %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="field">
7
7
  <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true %>
8
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="field">
7
7
  <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true %>
8
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9
9
  </div>
10
10
 
11
11
  <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="field">
7
7
  <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true %>
8
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9
9
  </div>
10
10
 
11
11
  <div class="field">
@@ -3,7 +3,7 @@
3
3
  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
4
  <div class="field">
5
5
  <%= f.label :email %><br />
6
- <%= f.email_field :email, autofocus: true %>
6
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
7
7
  </div>
8
8
 
9
9
  <div class="field">
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="field">
7
7
  <%= f.label :email %><br />
8
- <%= f.email_field :email, autofocus: true %>
8
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %>
9
9
  </div>
10
10
 
11
11
  <div class="actions">
@@ -23,6 +23,8 @@ en:
23
23
  subject: "Reset password instructions"
24
24
  unlock_instructions:
25
25
  subject: "Unlock instructions"
26
+ email_changed:
27
+ subject: "Email Changed"
26
28
  password_change:
27
29
  subject: "Password Changed"
28
30
  omniauth_callbacks:
data/devise.gemspec CHANGED
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
2
4
  $:.push File.expand_path("../lib", __FILE__)
3
5
  require "devise/version"
4
6
 
@@ -21,6 +23,6 @@ Gem::Specification.new do |s|
21
23
  s.add_dependency("warden", "~> 1.2.3")
22
24
  s.add_dependency("orm_adapter", "~> 0.1")
23
25
  s.add_dependency("bcrypt", "~> 3.0")
24
- s.add_dependency("railties", ">= 4.1.0", "< 5.1")
26
+ s.add_dependency("railties", ">= 4.1.0", "< 6.0")
25
27
  s.add_dependency("responders")
26
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec path: ".."
@@ -5,7 +7,7 @@ gemspec path: ".."
5
7
  gem "rails", github: "rails/rails", branch: "4-1-stable"
6
8
  gem "omniauth"
7
9
  gem "omniauth-oauth2"
8
- gem "rdoc"
10
+ gem "rdoc", "~> 5.1"
9
11
 
10
12
  group :test do
11
13
  gem "omniauth-facebook"
@@ -1,76 +1,71 @@
1
1
  GIT
2
2
  remote: git://github.com/rails/rails.git
3
- revision: 9f5cbe613c8a80282970c73b0f00095788d54e34
3
+ revision: 0cad778c2605a5204a05a9f1dbd3344e39f248d8
4
4
  branch: 4-1-stable
5
5
  specs:
6
- actionmailer (4.1.15)
7
- actionpack (= 4.1.15)
8
- actionview (= 4.1.15)
6
+ actionmailer (4.1.16)
7
+ actionpack (= 4.1.16)
8
+ actionview (= 4.1.16)
9
9
  mail (~> 2.5, >= 2.5.4)
10
- actionpack (4.1.15)
11
- actionview (= 4.1.15)
12
- activesupport (= 4.1.15)
13
- rack (~> 1.5.2)
14
- rack-test (~> 0.6.2)
15
- actionview (4.1.15)
16
- activesupport (= 4.1.15)
17
- builder (~> 3.1)
18
- erubis (~> 2.7.0)
19
- activemodel (4.1.15)
20
- activesupport (= 4.1.15)
21
- builder (~> 3.1)
22
- activerecord (4.1.15)
23
- activemodel (= 4.1.15)
24
- activesupport (= 4.1.15)
25
- arel (~> 5.0.0)
26
- activesupport (4.1.15)
27
- i18n (~> 0.6, >= 0.6.9)
28
- json (~> 1.7, >= 1.7.7)
29
- minitest (~> 5.1)
30
- thread_safe (~> 0.1)
31
- tzinfo (~> 1.1)
32
- rails (4.1.15)
33
- actionmailer (= 4.1.15)
34
- actionpack (= 4.1.15)
35
- actionview (= 4.1.15)
36
- activemodel (= 4.1.15)
37
- activerecord (= 4.1.15)
38
- activesupport (= 4.1.15)
10
+ rails (4.1.16)
11
+ actionmailer (= 4.1.16)
12
+ actionpack (= 4.1.16)
13
+ actionview (= 4.1.16)
14
+ activemodel (= 4.1.16)
15
+ activerecord (= 4.1.16)
16
+ activesupport (= 4.1.16)
39
17
  bundler (>= 1.3.0, < 2.0)
40
- railties (= 4.1.15)
18
+ railties (= 4.1.16)
41
19
  sprockets-rails (~> 2.0)
42
- railties (4.1.15)
43
- actionpack (= 4.1.15)
44
- activesupport (= 4.1.15)
45
- rake (>= 0.8.7)
46
- thor (>= 0.18.1, < 2.0)
47
20
 
48
21
  PATH
49
22
  remote: ..
50
23
  specs:
51
- devise (4.2.0)
24
+ devise (4.4.3)
52
25
  bcrypt (~> 3.0)
53
26
  orm_adapter (~> 0.1)
54
- railties (>= 4.1.0, < 5.1)
27
+ railties (>= 4.1.0, < 6.0)
55
28
  responders
56
29
  warden (~> 1.2.3)
57
30
 
58
31
  GEM
59
32
  remote: https://rubygems.org/
60
33
  specs:
34
+ actionpack (4.1.16)
35
+ actionview (= 4.1.16)
36
+ activesupport (= 4.1.16)
37
+ rack (~> 1.5.2)
38
+ rack-test (~> 0.6.2)
39
+ actionview (4.1.16)
40
+ activesupport (= 4.1.16)
41
+ builder (~> 3.1)
42
+ erubis (~> 2.7.0)
43
+ activemodel (4.1.16)
44
+ activesupport (= 4.1.16)
45
+ builder (~> 3.1)
46
+ activerecord (4.1.16)
47
+ activemodel (= 4.1.16)
48
+ activesupport (= 4.1.16)
49
+ arel (~> 5.0.0)
50
+ activesupport (4.1.16)
51
+ i18n (~> 0.6, >= 0.6.9)
52
+ json (~> 1.7, >= 1.7.7)
53
+ minitest (~> 5.1)
54
+ thread_safe (~> 0.1)
55
+ tzinfo (~> 1.1)
61
56
  arel (5.0.1.20140414130214)
62
57
  bcrypt (3.1.11)
63
58
  bson (3.2.6)
64
- builder (3.2.2)
65
- concurrent-ruby (1.0.2)
66
- connection_pool (2.2.0)
59
+ builder (3.2.3)
60
+ concurrent-ruby (1.0.5)
61
+ connection_pool (2.2.1)
67
62
  erubis (2.7.0)
68
- faraday (0.9.2)
63
+ faraday (0.11.0)
69
64
  multipart-post (>= 1.2, < 3)
70
- hashie (3.4.4)
71
- i18n (0.7.0)
72
- json (1.8.3)
73
- jwt (1.5.4)
65
+ hashie (3.5.5)
66
+ i18n (0.8.1)
67
+ json (1.8.6)
68
+ jwt (1.5.6)
74
69
  mail (2.6.4)
75
70
  mime-types (>= 1.16, < 4)
76
71
  metaclass (0.0.4)
@@ -78,8 +73,8 @@ GEM
78
73
  mime-types-data (~> 3.2015)
79
74
  mime-types-data (3.2016.0521)
80
75
  mini_portile2 (2.1.0)
81
- minitest (5.9.0)
82
- mocha (1.1.0)
76
+ minitest (5.10.1)
77
+ mocha (1.2.1)
83
78
  metaclass (~> 0.0.1)
84
79
  mongoid (4.0.2)
85
80
  activemodel (~> 4.0)
@@ -91,21 +86,20 @@ GEM
91
86
  connection_pool (~> 2.0)
92
87
  optionable (~> 0.2.0)
93
88
  multi_json (1.12.1)
94
- multi_xml (0.5.5)
89
+ multi_xml (0.6.0)
95
90
  multipart-post (2.0.0)
96
- nokogiri (1.6.8)
91
+ nokogiri (1.7.0.1)
97
92
  mini_portile2 (~> 2.1.0)
98
- pkg-config (~> 1.1.7)
99
- oauth2 (1.2.0)
100
- faraday (>= 0.8, < 0.10)
93
+ oauth2 (1.3.1)
94
+ faraday (>= 0.8, < 0.12)
101
95
  jwt (~> 1.0)
102
96
  multi_json (~> 1.3)
103
97
  multi_xml (~> 0.5)
104
98
  rack (>= 1.2, < 3)
105
- omniauth (1.3.1)
99
+ omniauth (1.4.2)
106
100
  hashie (>= 1.2, < 4)
107
101
  rack (>= 1.0, < 3)
108
- omniauth-facebook (3.0.0)
102
+ omniauth-facebook (4.0.0)
109
103
  omniauth-oauth2 (~> 1.2)
110
104
  omniauth-oauth2 (1.4.0)
111
105
  oauth2 (~> 1.0)
@@ -114,36 +108,39 @@ GEM
114
108
  omniauth (~> 1.0)
115
109
  rack-openid (~> 1.3.1)
116
110
  optionable (0.2.0)
117
- origin (2.2.0)
111
+ origin (2.3.0)
118
112
  orm_adapter (0.5.0)
119
- pkg-config (1.1.7)
120
113
  rack (1.5.5)
121
114
  rack-openid (1.3.1)
122
115
  rack (>= 1.1.0)
123
116
  ruby-openid (>= 2.1.8)
124
117
  rack-test (0.6.3)
125
118
  rack (>= 1.0)
126
- rake (11.2.2)
127
- rdoc (4.2.2)
128
- json (~> 1.4)
119
+ railties (4.1.16)
120
+ actionpack (= 4.1.16)
121
+ activesupport (= 4.1.16)
122
+ rake (>= 0.8.7)
123
+ thor (>= 0.18.1, < 2.0)
124
+ rake (12.0.0)
125
+ rdoc (5.1.0)
129
126
  responders (1.1.2)
130
127
  railties (>= 3.2, < 4.2)
131
128
  ruby-openid (2.7.0)
132
- sprockets (3.6.2)
129
+ sprockets (3.7.1)
133
130
  concurrent-ruby (~> 1.0)
134
131
  rack (> 1, < 3)
135
132
  sprockets-rails (2.3.3)
136
133
  actionpack (>= 3.0)
137
134
  activesupport (>= 3.0)
138
135
  sprockets (>= 2.8, < 4.0)
139
- sqlite3 (1.3.11)
136
+ sqlite3 (1.3.13)
140
137
  test_after_commit (1.1.0)
141
138
  activerecord (>= 3.2)
142
- thor (0.19.1)
143
- thread_safe (0.3.5)
139
+ thor (0.19.4)
140
+ thread_safe (0.3.6)
144
141
  tzinfo (1.2.2)
145
142
  thread_safe (~> 0.1)
146
- warden (1.2.6)
143
+ warden (1.2.7)
147
144
  rack (>= 1.0)
148
145
  webrat (0.7.3)
149
146
  nokogiri (>= 1.2.0)
@@ -165,10 +162,10 @@ DEPENDENCIES
165
162
  omniauth-oauth2
166
163
  omniauth-openid
167
164
  rails!
168
- rdoc
165
+ rdoc (~> 5.1)
169
166
  sqlite3
170
167
  test_after_commit
171
168
  webrat (= 0.7.3)
172
169
 
173
170
  BUNDLED WITH
174
- 1.12.5
171
+ 1.16.1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  gemspec path: ".."
@@ -5,7 +7,7 @@ gemspec path: ".."
5
7
  gem "rails", github: "rails/rails", branch: "4-2-stable"
6
8
  gem "omniauth"
7
9
  gem "omniauth-oauth2"
8
- gem "rdoc"
10
+ gem "rdoc", "~> 5.1"
9
11
 
10
12
  group :test do
11
13
  gem "omniauth-facebook"