devise 3.0.0 → 3.1.0

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 (68) hide show
  1. data/{CHANGELOG.rdoc → CHANGELOG.md} +67 -25
  2. data/Gemfile.lock +13 -12
  3. data/README.md +19 -17
  4. data/app/controllers/devise/confirmations_controller.rb +11 -3
  5. data/app/controllers/devise/registrations_controller.rb +9 -3
  6. data/app/controllers/devise/sessions_controller.rb +1 -1
  7. data/app/mailers/devise/mailer.rb +6 -3
  8. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  9. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  10. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  11. data/app/views/devise/shared/_links.erb +2 -2
  12. data/config/locales/en.yml +4 -3
  13. data/devise.gemspec +1 -0
  14. data/gemfiles/Gemfile.rails-3.2.x.lock +47 -44
  15. data/lib/devise/controllers/helpers.rb +1 -0
  16. data/lib/devise/controllers/rememberable.rb +1 -0
  17. data/lib/devise/hooks/csrf_cleaner.rb +5 -0
  18. data/lib/devise/hooks/lockable.rb +1 -1
  19. data/lib/devise/hooks/rememberable.rb +2 -1
  20. data/lib/devise/mailers/helpers.rb +0 -6
  21. data/lib/devise/models/authenticatable.rb +9 -16
  22. data/lib/devise/models/confirmable.rb +34 -43
  23. data/lib/devise/models/lockable.rb +15 -17
  24. data/lib/devise/models/recoverable.rb +21 -27
  25. data/lib/devise/models/rememberable.rb +6 -2
  26. data/lib/devise/models/timeoutable.rb +1 -1
  27. data/lib/devise/models/token_authenticatable.rb +4 -1
  28. data/lib/devise/models.rb +8 -12
  29. data/lib/devise/parameter_sanitizer.rb +49 -19
  30. data/lib/devise/rails/routes.rb +12 -9
  31. data/lib/devise/rails/warden_compat.rb +10 -2
  32. data/lib/devise/rails.rb +7 -11
  33. data/lib/devise/strategies/authenticatable.rb +0 -12
  34. data/lib/devise/token_generator.rb +70 -0
  35. data/lib/devise/version.rb +1 -1
  36. data/lib/devise.rb +23 -12
  37. data/lib/generators/active_record/devise_generator.rb +2 -5
  38. data/lib/generators/active_record/templates/migration.rb +0 -1
  39. data/lib/generators/active_record/templates/migration_existing.rb +0 -1
  40. data/lib/generators/devise/orm_helpers.rb +25 -6
  41. data/lib/generators/mongoid/devise_generator.rb +2 -2
  42. data/lib/generators/templates/devise.rb +21 -9
  43. data/test/controllers/helpers_test.rb +1 -1
  44. data/test/controllers/passwords_controller_test.rb +4 -5
  45. data/test/failure_app_test.rb +1 -1
  46. data/test/generators/active_record_generator_test.rb +31 -1
  47. data/test/integration/authenticatable_test.rb +15 -1
  48. data/test/integration/confirmable_test.rb +29 -42
  49. data/test/integration/http_authenticatable_test.rb +1 -1
  50. data/test/integration/lockable_test.rb +11 -14
  51. data/test/integration/recoverable_test.rb +23 -24
  52. data/test/integration/rememberable_test.rb +15 -13
  53. data/test/mailers/confirmation_instructions_test.rb +6 -2
  54. data/test/mailers/reset_password_instructions_test.rb +6 -2
  55. data/test/mailers/unlock_instructions_test.rb +6 -2
  56. data/test/models/confirmable_test.rb +38 -27
  57. data/test/models/lockable_test.rb +15 -5
  58. data/test/models/recoverable_test.rb +20 -48
  59. data/test/models/rememberable_test.rb +8 -0
  60. data/test/models/timeoutable_test.rb +5 -0
  61. data/test/models_test.rb +0 -19
  62. data/test/parameter_sanitizer_test.rb +23 -9
  63. data/test/rails_app/config/initializers/devise.rb +3 -0
  64. data/test/rails_app/lib/shared_admin.rb +3 -0
  65. data/test/rails_app/lib/shared_user.rb +4 -0
  66. data/test/support/helpers.rb +0 -21
  67. metadata +42 -26
  68. data/app/views/devise/_links.erb +0 -3
@@ -1,13 +1,55 @@
1
+ == 3.1.0
2
+
3
+ Security announcement: http://blog.plataformatec.com.br/2013/08/devise-3-1-now-with-more-secure-defaults/
4
+
5
+ * backwards incompatible changes
6
+ * Do not store confirmation, unlock and reset password tokens directly in the database. This means tokens previously stored in the database are no longer valid. You can reenable this temporarily by setting `config.allow_insecure_tokens_lookup = true` in your configuration file. It is recommended to keep this configuration set to true just temporarily in your production servers only to aid migration
7
+ * The Devise mailer and its views were changed to explicitly receive a token argument as `@token`. You will need to update your mailers and re-copy the views to your application with `rails g devise:views`
8
+ * Sanitization of parameters should be done by calling `devise_parameter_sanitizer.sanitize(:action)` instead of `devise_parameter_sanitizer.for(:action)`
9
+
10
+ * deprecations
11
+ * Token authentication is deprecated
12
+
13
+ * enhancements
14
+ * Better security defaults
15
+ * Allow easier customization of parameter sanitizer (by @alexpeattie)
16
+
17
+ * bug fix
18
+ * Do not confirm e-mail after password reset (by @moll)
19
+ * Do not sign in after confirmation
20
+ * Do not store confirmation, unlock and reset password tokens directly in the database
21
+ * Do not compare directly against confirmation, unlock and reset password tokens
22
+ * Skip storage for cookies on unverified requests
23
+
24
+ == 3.0.2
25
+
26
+ * bug fix
27
+ * Skip storage for cookies on unverified requests
28
+
29
+ == 3.0.1
30
+
31
+ Security announcement: http://blog.plataformatec.com.br/2013/08/csrf-token-fixation-attacks-in-devise/
32
+
33
+ * enhancements
34
+ * Add after_confirmation callback
35
+
36
+ * bug fix
37
+ * When using rails 3.2, the generator adds 'attr_accessible' to the model (by @jcoyne)
38
+ * Clean up CSRF token after authentication (by @homakov). Notice this change will clean up the CSRF Token after authentication (sign in, sign up, etc). So if you are using AJAX for such features, you will need to fetch a new CSRF token from the server.
39
+
1
40
  == 3.0.0
2
41
 
3
42
  * enhancements
4
43
  * Rails 4 and Strong Parameters compatibility (by @carlosantoniodasilva, @josevalim, @latortuga, @lucasmazza, @nashby, @rafaelfranca, @spastorino)
5
44
  * Drop support for Rails < 3.2 and Ruby < 1.9.3
6
- * Enable to skip sending reconfirmation email when reconfirmable is on and skip_confirmation_notification! is invoked (by @tkhr)
45
+ * Enable to skip sending reconfirmation email when reconfirmable is on and `skip_confirmation_notification!` is invoked (by @tkhr)
7
46
 
8
47
  * bug fix
9
48
  * Errors on unlock are now properly reflected on the first `unlock_keys`
10
49
 
50
+ * backwards incompatible changes
51
+ * Changes on session storage will expire all existing sessions on upgrade
52
+
11
53
  == 2.2.4
12
54
 
13
55
  * enhancements
@@ -624,7 +666,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
624
666
  * Added Registerable
625
667
  * Added Http Basic Authentication support
626
668
  * Allow scoped_views to be customized per controller/mailer class
627
- * [#99] Allow authenticatable to used in change_table statements
669
+ * Allow authenticatable to used in change_table statements
628
670
 
629
671
  == 0.9.2
630
672
 
@@ -764,19 +806,19 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
764
806
  * Added DataMapper support
765
807
  * Remove store_location from authenticatable strategy and add it to failure app
766
808
  * Allow a strategy to be placed after authenticatable
767
- * [#45] Do not rely attribute? methods, since they are not added on Datamapper
809
+ * Do not rely attribute? methods, since they are not added on Datamapper
768
810
 
769
811
  == 0.5.6
770
812
 
771
813
  * enhancements
772
- * [#42] Do not send nil to build (DataMapper compatibility)
773
- * [#44] Allow to have scoped views
814
+ * Do not send nil to build (DataMapper compatibility)
815
+ * Allow to have scoped views
774
816
 
775
817
  == 0.5.5
776
818
 
777
819
  * enhancements
778
820
  * Allow overwriting find for authentication method
779
- * [#38] Remove Ruby 1.8.7 dependency
821
+ * Remove Ruby 1.8.7 dependency
780
822
 
781
823
  == 0.5.4
782
824
 
@@ -784,7 +826,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
784
826
  * Deprecate :singular in devise_for and use :scope instead
785
827
 
786
828
  * enhancements
787
- * [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
829
+ * Create after_sign_in_path_for and after_sign_out_path_for hooks to be
788
830
  overwriten in ApplicationController
789
831
  * Create sign_in_and_redirect and sign_out_and_redirect helpers
790
832
  * Warden::Manager.default_scope is automatically configured to the first given scope
@@ -796,7 +838,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
796
838
  * Ensure all controllers are unloadable
797
839
 
798
840
  * enhancements
799
- * [#35] Moved friendly_token to Devise
841
+ * Moved friendly_token to Devise
800
842
  * Added Devise.all, so you can freeze your app strategies
801
843
  * Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
802
844
  in cases you don't want it be handlded automatically
@@ -804,9 +846,9 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
804
846
  == 0.5.2
805
847
 
806
848
  * enhancements
807
- * [#28] Improved sign_in and sign_out helpers to accepts resources
808
- * [#28] Added stored_location_for as a helper
809
- * [#20] Added test helpers
849
+ * Improved sign_in and sign_out helpers to accepts resources
850
+ * Added stored_location_for as a helper
851
+ * Added test helpers
810
852
 
811
853
  == 0.5.1
812
854
 
@@ -827,7 +869,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
827
869
  == 0.4.3
828
870
 
829
871
  * bug fix
830
- * [#29] Authentication just fails if user cannot be serialized from session, without raising errors;
872
+ * Authentication just fails if user cannot be serialized from session, without raising errors;
831
873
  * Default configuration values should not overwrite user values;
832
874
 
833
875
  == 0.4.2
@@ -845,7 +887,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
845
887
  == 0.4.1
846
888
 
847
889
  * bug fix
848
- * [#21] Ensure options can be set even if models were not loaded
890
+ * Ensure options can be set even if models were not loaded
849
891
 
850
892
  == 0.4.0
851
893
 
@@ -856,25 +898,25 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
856
898
  * :authenticable calls are deprecated, use :authenticatable instead
857
899
 
858
900
  * enhancements
859
- * [#16] Allow devise to be more agnostic and do not require ActiveRecord to be loaded
901
+ * Allow devise to be more agnostic and do not require ActiveRecord to be loaded
860
902
  * Allow Warden::Manager to be configured through Devise
861
903
  * Created a generator which creates an initializer
862
904
 
863
905
  == 0.3.0
864
906
 
865
907
  * bug fix
866
- * [#15] Allow yml messages to be configured by not using engine locales
908
+ * Allow yml messages to be configured by not using engine locales
867
909
 
868
910
  * deprecations
869
911
  * Renamed confirm_in to confirm_within
870
- * [#14] Do not send confirmation messages when user changes his e-mail
871
- * [#13] Renamed authenticable to authenticatable and added deprecation warnings
912
+ * Do not send confirmation messages when user changes his e-mail
913
+ * Renamed authenticable to authenticatable and added deprecation warnings
872
914
 
873
915
  == 0.2.3
874
916
 
875
917
  * enhancements
876
918
  * Ensure fail! works inside strategies
877
- * [#12] Make unauthenticated message (when you haven't signed in) different from invalid message
919
+ * Make unauthenticated message (when you haven't signed in) different from invalid message
878
920
 
879
921
  * bug fix
880
922
  * Do not redirect on invalid authenticate
@@ -883,7 +925,7 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
883
925
  == 0.2.2
884
926
 
885
927
  * bug fix
886
- * [#9] Fix a bug when using customized resources
928
+ * Fix a bug when using customized resources
887
929
 
888
930
  == 0.2.1
889
931
 
@@ -891,17 +933,17 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
891
933
  * Clean devise_views generator to use devise existing views
892
934
 
893
935
  * enhancements
894
- * [#7] Create instance variables (like @user) for each devise controller
936
+ * Create instance variables (like @user) for each devise controller
895
937
  * Use Devise::Controller::Helpers only internally
896
938
 
897
939
  * bug fix
898
- * [#6] Fix a bug with Mongrel and Ruby 1.8.6
940
+ * Fix a bug with Mongrel and Ruby 1.8.6
899
941
 
900
942
  == 0.2.0
901
943
 
902
944
  * enhancements
903
- * [#4] Allow option :null => true in authenticable migration
904
- * [#3] Remove attr_accessible calls from devise modules
945
+ * Allow option :null => true in authenticable migration
946
+ * Remove attr_accessible calls from devise modules
905
947
  * Customizable time frame for rememberable with :remember_for config
906
948
  * Customizable time frame for confirmable with :confirm_in config
907
949
  * Generators for creating a resource and copy views
@@ -910,12 +952,12 @@ Notes: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.
910
952
  * Do not load hooks or strategies if they are not used
911
953
 
912
954
  * bug fixes
913
- * [#2] Fixed requiring devise strategies
955
+ * Fixed requiring devise strategies
914
956
 
915
957
  == 0.1.1
916
958
 
917
959
  * bug fixes
918
- * [#1] Fixed requiring devise mapping
960
+ * Fixed requiring devise mapping
919
961
 
920
962
  == 0.1.0
921
963
 
data/Gemfile.lock CHANGED
@@ -1,21 +1,22 @@
1
1
  GIT
2
2
  remote: git://github.com/mongoid/mongoid.git
3
- revision: fe7f43430580860db6d1d89cea27eda24ab60ab1
3
+ revision: 346a79a7d01aa194de80e649916239a18d38ce13
4
4
  branch: master
5
5
  specs:
6
6
  mongoid (4.0.0)
7
- activemodel (~> 4.0.0.rc1)
8
- moped (~> 1.4.2)
7
+ activemodel (~> 4.0.0)
8
+ moped (~> 1.5)
9
9
  origin (~> 1.0)
10
10
  tzinfo (~> 0.3.22)
11
11
 
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- devise (3.0.0.rc)
15
+ devise (3.1.0)
16
16
  bcrypt-ruby (~> 3.0)
17
17
  orm_adapter (~> 0.1)
18
18
  railties (>= 3.2.6, < 5)
19
+ thread_safe (~> 0.1)
19
20
  warden (~> 1.2.3)
20
21
 
21
22
  GEM
@@ -46,17 +47,17 @@ GEM
46
47
  thread_safe (~> 0.1)
47
48
  tzinfo (~> 0.3.37)
48
49
  arel (4.0.0)
49
- atomic (1.1.10)
50
+ atomic (1.1.12)
50
51
  bcrypt-ruby (3.1.1)
51
52
  builder (3.1.4)
52
53
  erubis (2.7.0)
53
- faraday (0.8.7)
54
- multipart-post (~> 1.1)
54
+ faraday (0.8.8)
55
+ multipart-post (~> 1.2.0)
55
56
  hashie (1.2.0)
56
57
  hike (1.2.3)
57
58
  httpauth (0.2.0)
58
- i18n (0.6.4)
59
- json (1.7.7)
59
+ i18n (0.6.5)
60
+ json (1.8.0)
60
61
  jwt (0.1.8)
61
62
  multi_json (>= 1.5)
62
63
  mail (2.5.4)
@@ -67,8 +68,8 @@ GEM
67
68
  minitest (4.7.5)
68
69
  mocha (0.13.3)
69
70
  metaclass (~> 0.0.1)
70
- moped (1.4.5)
71
- multi_json (1.7.7)
71
+ moped (1.5.1)
72
+ multi_json (1.7.9)
72
73
  multipart-post (1.2.0)
73
74
  nokogiri (1.5.9)
74
75
  oauth2 (0.8.1)
@@ -125,7 +126,7 @@ GEM
125
126
  sprockets (~> 2.8)
126
127
  sqlite3 (1.3.7)
127
128
  thor (0.18.1)
128
- thread_safe (0.1.0)
129
+ thread_safe (0.1.2)
129
130
  atomic
130
131
  tilt (1.4.1)
131
132
  treetop (1.4.14)
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  By [Plataformatec](http://plataformatec.com.br/).
4
4
 
5
- [![Gem Version](https://fury-badge.herokuapp.com/rb/devise.png)](http://badge.fury.io/rb/devise)
6
5
  [![Build Status](https://api.travis-ci.org/plataformatec/devise.png?branch=master)](http://travis-ci.org/plataformatec/devise)
7
6
  [![Code Climate](https://codeclimate.com/github/plataformatec/devise.png)](https://codeclimate.com/github/plataformatec/devise)
8
7
 
@@ -12,13 +11,12 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
12
11
 
13
12
  * Is Rack based;
14
13
  * Is a complete MVC solution based on Rails engines;
15
- * Allows you to have multiple roles (or models/scopes) signed in at the same time;
14
+ * Allows you to have multiple models signed in at the same time;
16
15
  * Is based on a modularity concept: use just what you really need.
17
16
 
18
- It's composed of 11 modules:
17
+ It's composed of 10 modules:
19
18
 
20
19
  * [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts 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.
21
- * [Token Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable): signs in a user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
22
20
  * [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds Omniauth (https://github.com/intridea/omniauth) support;
23
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.
24
22
  * [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
@@ -188,7 +186,7 @@ There are just three actions in Devise that allows any set of parameters to be p
188
186
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
189
187
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
190
188
 
191
- In case you want to customize the permitted parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
189
+ In case you want to permit additional parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
192
190
 
193
191
  ```ruby
194
192
  class ApplicationController < ActionController::Base
@@ -197,12 +195,20 @@ class ApplicationController < ActionController::Base
197
195
  protected
198
196
 
199
197
  def configure_permitted_parameters
200
- devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
198
+ devise_parameter_sanitizer.for(:sign_up) << :username
201
199
  end
202
200
  end
203
201
  ```
204
202
 
205
- If you have multiple roles, you may want to set up different parameter sanitizer per role. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and add your own logic:
203
+ To completely change Devise defaults or invoke custom behaviour, you can also pass a block:
204
+
205
+ ```ruby
206
+ def configure_permitted_parameters
207
+ devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
208
+ end
209
+ ```
210
+
211
+ If you have multiple Devise models, you may want to set up different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and add your own logic:
206
212
 
207
213
  ```ruby
208
214
  class User::ParameterSanitizer < Devise::ParameterSanitizer
@@ -240,7 +246,7 @@ Since Devise is an engine, all its views are packaged inside the gem. These view
240
246
  rails generate devise:views
241
247
  ```
242
248
 
243
- If you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
249
+ If you have more than one Devise model in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
244
250
 
245
251
  After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new". You can also use the generator to generate scoped views:
246
252
 
@@ -252,7 +258,7 @@ rails generate devise:views users
252
258
 
253
259
  If the customization at the views level is not enough, you can customize each controller by following these steps:
254
260
 
255
- 1. Create your custom controller, for example a `Admins::SessionsController`:
261
+ 1. Create your custom controller, for example a `Admins::SessionsController`:
256
262
 
257
263
  ```ruby
258
264
  class Admins::SessionsController < Devise::SessionsController
@@ -384,7 +390,7 @@ You can read more about Omniauth support in the wiki:
384
390
 
385
391
  ### Configuring multiple models
386
392
 
387
- Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication and timeoutable features. If so, just follow these steps:
393
+ Devise allows you to set up as many Devise models as you want. If you want to have an Admin model with just authentication and timeout features, in addition to the User model above, just run:
388
394
 
389
395
  ```ruby
390
396
  # Create a migration with the required fields
@@ -409,7 +415,9 @@ current_admin
409
415
  admin_session
410
416
  ```
411
417
 
412
- On the other hand, you can simply run the generator!
418
+ Alternatively, you can simply run the Devise generator.
419
+
420
+ Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend you to use a role-based approach, by either providing a role column or using [CanCan](https://github.com/ryanb/cancan).
413
421
 
414
422
  ### Other ORMs
415
423
 
@@ -439,12 +447,6 @@ We have a long list of valued contributors. Check them all at:
439
447
 
440
448
  https://github.com/plataformatec/devise/contributors
441
449
 
442
- ### Maintainers
443
-
444
- * José Valim (https://github.com/josevalim)
445
- * Carlos Antônio da Silva (https://github.com/carlosantoniodasilva)
446
- * Rodrigo Flores (https://github.com/rodrigoflores)
447
-
448
450
  ## License
449
451
 
450
452
  MIT License. Copyright 2009-2013 Plataformatec. http://plataformatec.com.br
@@ -20,8 +20,12 @@ class Devise::ConfirmationsController < DeviseController
20
20
  self.resource = resource_class.confirm_by_token(params[:confirmation_token])
21
21
 
22
22
  if resource.errors.empty?
23
- set_flash_message(:notice, :confirmed) if is_navigational_format?
24
- sign_in(resource_name, resource)
23
+ if Devise.allow_insecure_sign_in_after_confirmation
24
+ set_flash_message(:notice, :confirmed_and_signed_in) if is_navigational_format?
25
+ sign_in(resource_name, resource)
26
+ else
27
+ set_flash_message(:notice, :confirmed) if is_navigational_format?
28
+ end
25
29
  respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
26
30
  else
27
31
  respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new }
@@ -37,6 +41,10 @@ class Devise::ConfirmationsController < DeviseController
37
41
 
38
42
  # The path used after confirmation.
39
43
  def after_confirmation_path_for(resource_name, resource)
40
- after_sign_in_path_for(resource)
44
+ if Devise.allow_insecure_sign_in_after_confirmation
45
+ after_sign_in_path_for(resource)
46
+ else
47
+ new_session_path(resource_name)
48
+ end
41
49
  end
42
50
  end
@@ -40,7 +40,7 @@ class Devise::RegistrationsController < DeviseController
40
40
  self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
41
41
  prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
42
42
 
43
- if resource.update_with_password(account_update_params)
43
+ if update_resource(resource, account_update_params)
44
44
  if is_navigational_format?
45
45
  flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
46
46
  :update_needs_confirmation : :updated
@@ -80,6 +80,12 @@ class Devise::RegistrationsController < DeviseController
80
80
  previous != resource.unconfirmed_email
81
81
  end
82
82
 
83
+ # By default we want to require a password checks on update.
84
+ # You can overwrite this method in your own RegistrationsController.
85
+ def update_resource(resource, params)
86
+ resource.update_with_password(params)
87
+ end
88
+
83
89
  # Build a devise resource passing in the session. Useful to move
84
90
  # temporary session data to the newly created user.
85
91
  def build_resource(hash=nil)
@@ -117,10 +123,10 @@ class Devise::RegistrationsController < DeviseController
117
123
  end
118
124
 
119
125
  def sign_up_params
120
- devise_parameter_sanitizer.for(:sign_up)
126
+ devise_parameter_sanitizer.sanitize(:sign_up)
121
127
  end
122
128
 
123
129
  def account_update_params
124
- devise_parameter_sanitizer.for(:account_update)
130
+ devise_parameter_sanitizer.sanitize(:account_update)
125
131
  end
126
132
  end
@@ -35,7 +35,7 @@ class Devise::SessionsController < DeviseController
35
35
  protected
36
36
 
37
37
  def sign_in_params
38
- devise_parameter_sanitizer.for(:sign_in)
38
+ devise_parameter_sanitizer.sanitize(:sign_in)
39
39
  end
40
40
 
41
41
  def serialize_options(resource)
@@ -1,15 +1,18 @@
1
1
  class Devise::Mailer < Devise.parent_mailer.constantize
2
2
  include Devise::Mailers::Helpers
3
3
 
4
- def confirmation_instructions(record, opts={})
4
+ def confirmation_instructions(record, token, opts={})
5
+ @token = token
5
6
  devise_mail(record, :confirmation_instructions, opts)
6
7
  end
7
8
 
8
- def reset_password_instructions(record, opts={})
9
+ def reset_password_instructions(record, token, opts={})
10
+ @token = token
9
11
  devise_mail(record, :reset_password_instructions, opts)
10
12
  end
11
13
 
12
- def unlock_instructions(record, opts={})
14
+ def unlock_instructions(record, token, opts={})
15
+ @token = token
13
16
  devise_mail(record, :unlock_instructions, opts)
14
17
  end
15
18
  end
@@ -2,4 +2,4 @@
2
2
 
3
3
  <p>You can confirm your account email through the link below:</p>
4
4
 
5
- <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
@@ -2,7 +2,7 @@
2
2
 
3
3
  <p>Someone has requested a link to change your password. You can do this through the link below.</p>
4
4
 
5
- <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %></p>
6
6
 
7
7
  <p>If you didn't request this, please ignore this email.</p>
8
8
  <p>Your password won't change until you access the link above and create a new one.</p>
@@ -4,4 +4,4 @@
4
4
 
5
5
  <p>Click the link below to unlock your account:</p>
6
6
 
7
- <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @token) %></p>
@@ -6,7 +6,7 @@
6
6
  <%= link_to "Sign up", new_registration_path(resource_name) %><br />
7
7
  <% end -%>
8
8
 
9
- <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
9
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
10
10
  <%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
11
11
  <% end -%>
12
12
 
@@ -22,4 +22,4 @@
22
22
  <%- resource_class.omniauth_providers.each do |provider| %>
23
23
  <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
24
24
  <% end -%>
25
- <% end -%>
25
+ <% end -%>
@@ -3,17 +3,18 @@
3
3
  en:
4
4
  devise:
5
5
  confirmations:
6
- confirmed: "Your account was successfully confirmed. You are now signed in."
6
+ confirmed: "Your account was successfully confirmed. Please sign in."
7
+ confirmed_and_signed_in: "Your account was successfully confirmed. You are now signed in."
7
8
  send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
8
9
  send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
9
10
  failure:
10
11
  already_authenticated: "You are already signed in."
11
- inactive: "Your account was not activated yet."
12
+ inactive: "Your account is not activated yet."
12
13
  invalid: "Invalid email or password."
13
14
  invalid_token: "Invalid authentication token."
14
15
  locked: "Your account is locked."
15
16
  not_found_in_database: "Invalid email or password."
16
- timeout: "Your session expired, please sign in again to continue."
17
+ timeout: "Your session expired. Please sign in again to continue."
17
18
  unauthenticated: "You need to sign in or sign up before continuing."
18
19
  unconfirmed: "You have to confirm your account before continuing."
19
20
  mailer:
data/devise.gemspec CHANGED
@@ -22,5 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency("warden", "~> 1.2.3")
23
23
  s.add_dependency("orm_adapter", "~> 0.1")
24
24
  s.add_dependency("bcrypt-ruby", "~> 3.0")
25
+ s.add_dependency("thread_safe", "~> 0.1")
25
26
  s.add_dependency("railties", ">= 3.2.6", "< 5")
26
27
  end