devise 3.4.1 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +26 -16
  3. data/CHANGELOG.md +131 -104
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +84 -85
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +52 -32
  8. data/Rakefile +2 -1
  9. data/app/controllers/devise/confirmations_controller.rb +4 -0
  10. data/app/controllers/devise/omniauth_callbacks_controller.rb +4 -0
  11. data/app/controllers/devise/passwords_controller.rb +14 -4
  12. data/app/controllers/devise/registrations_controller.rb +10 -11
  13. data/app/controllers/devise/sessions_controller.rb +7 -2
  14. data/app/controllers/devise/unlocks_controller.rb +3 -0
  15. data/app/controllers/devise_controller.rb +34 -18
  16. data/app/views/devise/confirmations/new.html.erb +1 -1
  17. data/app/views/devise/passwords/edit.html.erb +3 -0
  18. data/app/views/devise/registrations/new.html.erb +1 -1
  19. data/gemfiles/Gemfile.rails-3.2-stable.lock +43 -43
  20. data/gemfiles/Gemfile.rails-4.0-stable.lock +45 -47
  21. data/gemfiles/Gemfile.rails-4.1-stable.lock +52 -53
  22. data/gemfiles/Gemfile.rails-4.2-stable +29 -0
  23. data/gemfiles/Gemfile.rails-4.2-stable.lock +191 -0
  24. data/lib/devise.rb +23 -28
  25. data/lib/devise/controllers/rememberable.rb +1 -1
  26. data/lib/devise/controllers/sign_in_out.rb +1 -1
  27. data/lib/devise/controllers/store_location.rb +3 -1
  28. data/lib/devise/controllers/url_helpers.rb +7 -9
  29. data/lib/devise/encryptor.rb +22 -0
  30. data/lib/devise/failure_app.rb +26 -10
  31. data/lib/devise/mapping.rb +1 -0
  32. data/lib/devise/models/authenticatable.rb +20 -26
  33. data/lib/devise/models/confirmable.rb +29 -7
  34. data/lib/devise/models/database_authenticatable.rb +6 -9
  35. data/lib/devise/models/recoverable.rb +22 -10
  36. data/lib/devise/models/rememberable.rb +16 -3
  37. data/lib/devise/models/trackable.rb +1 -2
  38. data/lib/devise/models/validatable.rb +3 -3
  39. data/lib/devise/rails.rb +1 -1
  40. data/lib/devise/rails/routes.rb +3 -3
  41. data/lib/devise/strategies/authenticatable.rb +5 -2
  42. data/lib/devise/strategies/database_authenticatable.rb +1 -1
  43. data/lib/devise/strategies/rememberable.rb +10 -0
  44. data/lib/devise/test_helpers.rb +2 -2
  45. data/lib/devise/version.rb +1 -1
  46. data/lib/generators/active_record/templates/migration.rb +1 -1
  47. data/lib/generators/active_record/templates/migration_existing.rb +1 -1
  48. data/lib/generators/templates/controllers/README +1 -1
  49. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  50. data/lib/generators/templates/controllers/registrations_controller.rb +2 -2
  51. data/lib/generators/templates/controllers/sessions_controller.rb +1 -1
  52. data/lib/generators/templates/devise.rb +14 -8
  53. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +1 -1
  54. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
  55. data/test/controllers/custom_registrations_controller_test.rb +6 -1
  56. data/test/controllers/helpers_test.rb +5 -0
  57. data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
  58. data/test/controllers/internal_helpers_test.rb +4 -4
  59. data/test/controllers/load_hooks_controller_test.rb +19 -0
  60. data/test/controllers/passwords_controller_test.rb +1 -1
  61. data/test/controllers/sessions_controller_test.rb +3 -3
  62. data/test/devise_test.rb +2 -2
  63. data/test/failure_app_test.rb +23 -0
  64. data/test/integration/database_authenticatable_test.rb +11 -0
  65. data/test/integration/omniauthable_test.rb +1 -1
  66. data/test/integration/recoverable_test.rb +13 -0
  67. data/test/integration/rememberable_test.rb +9 -0
  68. data/test/mapping_test.rb +6 -0
  69. data/test/models/confirmable_test.rb +47 -34
  70. data/test/models/lockable_test.rb +6 -6
  71. data/test/models/recoverable_test.rb +39 -7
  72. data/test/models/rememberable_test.rb +8 -2
  73. data/test/models/validatable_test.rb +5 -5
  74. data/test/rails_app/app/controllers/custom/registrations_controller.rb +10 -0
  75. data/test/rails_app/config/application.rb +1 -1
  76. data/test/rails_app/config/environments/production.rb +6 -2
  77. data/test/rails_app/config/environments/test.rb +7 -2
  78. data/test/rails_app/config/initializers/devise.rb +12 -15
  79. data/test/rails_app/lib/shared_user.rb +1 -1
  80. data/test/rails_test.rb +9 -0
  81. data/test/support/integration.rb +2 -2
  82. data/test/test_helpers_test.rb +22 -7
  83. data/test/test_models.rb +2 -2
  84. metadata +11 -2
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "4.2.0.beta2"
5
+ gem "rails", "4.2.1"
6
6
  gem "omniauth", "~> 1.2.0"
7
7
  gem "omniauth-oauth2", "~> 1.1.0"
8
8
  gem "rdoc"
@@ -1,18 +1,7 @@
1
- GIT
2
- remote: git://github.com/mongoid/mongoid.git
3
- revision: 5ba2e1fb4cb8189c9890e29c19cf4e16c25e4bc5
4
- branch: master
5
- specs:
6
- mongoid (4.0.0)
7
- activemodel (~> 4.0)
8
- moped (~> 2.0.0)
9
- origin (~> 2.1)
10
- tzinfo (>= 0.3.37)
11
-
12
1
  PATH
13
2
  remote: .
14
3
  specs:
15
- devise (3.4.1)
4
+ devise (3.5.1)
16
5
  bcrypt (~> 3.0)
17
6
  orm_adapter (~> 0.1)
18
7
  railties (>= 3.2.6, < 5)
@@ -20,78 +9,89 @@ PATH
20
9
  thread_safe (~> 0.1)
21
10
  warden (~> 1.2.3)
22
11
 
12
+ GIT
13
+ remote: git://github.com/mongoid/mongoid.git
14
+ revision: a4365d7ecfa8221bfcf36a4e7ce7993142fc5940
15
+ branch: master
16
+ specs:
17
+ mongoid (4.0.0)
18
+ activemodel (~> 4.0)
19
+ moped (~> 2.0.0)
20
+ origin (~> 2.1)
21
+ tzinfo (>= 0.3.37)
22
+
23
23
  GEM
24
24
  remote: https://rubygems.org/
25
25
  specs:
26
- actionmailer (4.2.0.beta2)
27
- actionpack (= 4.2.0.beta2)
28
- actionview (= 4.2.0.beta2)
29
- activejob (= 4.2.0.beta2)
26
+ actionmailer (4.2.1)
27
+ actionpack (= 4.2.1)
28
+ actionview (= 4.2.1)
29
+ activejob (= 4.2.1)
30
30
  mail (~> 2.5, >= 2.5.4)
31
- rails-dom-testing (~> 1.0, >= 1.0.3)
32
- actionpack (4.2.0.beta2)
33
- actionview (= 4.2.0.beta2)
34
- activesupport (= 4.2.0.beta2)
35
- rack (~> 1.6.0.beta)
31
+ rails-dom-testing (~> 1.0, >= 1.0.5)
32
+ actionpack (4.2.1)
33
+ actionview (= 4.2.1)
34
+ activesupport (= 4.2.1)
35
+ rack (~> 1.6)
36
36
  rack-test (~> 0.6.2)
37
- rails-dom-testing (~> 1.0, >= 1.0.3)
37
+ rails-dom-testing (~> 1.0, >= 1.0.5)
38
38
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
39
- actionview (4.2.0.beta2)
40
- activesupport (= 4.2.0.beta2)
39
+ actionview (4.2.1)
40
+ activesupport (= 4.2.1)
41
41
  builder (~> 3.1)
42
42
  erubis (~> 2.7.0)
43
- rails-dom-testing (~> 1.0, >= 1.0.3)
43
+ rails-dom-testing (~> 1.0, >= 1.0.5)
44
44
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
45
- activejob (4.2.0.beta2)
46
- activesupport (= 4.2.0.beta2)
45
+ activejob (4.2.1)
46
+ activesupport (= 4.2.1)
47
47
  globalid (>= 0.3.0)
48
- activemodel (4.2.0.beta2)
49
- activesupport (= 4.2.0.beta2)
48
+ activemodel (4.2.1)
49
+ activesupport (= 4.2.1)
50
50
  builder (~> 3.1)
51
- activerecord (4.2.0.beta2)
52
- activemodel (= 4.2.0.beta2)
53
- activesupport (= 4.2.0.beta2)
54
- arel (>= 6.0.0.beta1, < 6.1)
55
- activesupport (4.2.0.beta2)
56
- i18n (>= 0.7.0.beta1, < 0.8)
51
+ activerecord (4.2.1)
52
+ activemodel (= 4.2.1)
53
+ activesupport (= 4.2.1)
54
+ arel (~> 6.0)
55
+ activesupport (4.2.1)
56
+ i18n (~> 0.7)
57
57
  json (~> 1.7, >= 1.7.7)
58
58
  minitest (~> 5.1)
59
- thread_safe (~> 0.1)
59
+ thread_safe (~> 0.3, >= 0.3.4)
60
60
  tzinfo (~> 1.1)
61
- arel (6.0.0.beta1)
62
- bcrypt (3.1.7)
61
+ arel (6.0.0)
62
+ bcrypt (3.1.10)
63
63
  bson (2.3.0)
64
64
  builder (3.2.2)
65
- connection_pool (2.0.0)
65
+ connection_pool (2.1.3)
66
66
  erubis (2.7.0)
67
- faraday (0.9.0)
67
+ faraday (0.9.1)
68
68
  multipart-post (>= 1.2, < 3)
69
- globalid (0.3.0)
69
+ globalid (0.3.3)
70
70
  activesupport (>= 4.1.0)
71
- hashie (3.2.0)
71
+ hashie (3.4.0)
72
72
  hike (1.2.3)
73
- i18n (0.7.0.beta1)
74
- json (1.8.1)
75
- jwt (1.0.0)
73
+ i18n (0.7.0)
74
+ json (1.8.2)
75
+ jwt (1.4.1)
76
76
  loofah (2.0.1)
77
77
  nokogiri (>= 1.5.9)
78
- mail (2.6.1)
78
+ mail (2.6.3)
79
79
  mime-types (>= 1.16, < 3)
80
80
  metaclass (0.0.4)
81
- mime-types (2.3)
82
- mini_portile (0.6.0)
83
- minitest (5.4.2)
81
+ mime-types (2.4.3)
82
+ mini_portile (0.6.2)
83
+ minitest (5.5.1)
84
84
  mocha (1.1.0)
85
85
  metaclass (~> 0.0.1)
86
- moped (2.0.0)
86
+ moped (2.0.4)
87
87
  bson (~> 2.2)
88
88
  connection_pool (~> 2.0)
89
89
  optionable (~> 0.2.0)
90
- multi_json (1.10.1)
90
+ multi_json (1.11.0)
91
91
  multi_xml (0.5.5)
92
92
  multipart-post (2.0.0)
93
- nokogiri (1.6.3.1)
94
- mini_portile (= 0.6.0)
93
+ nokogiri (1.6.6.2)
94
+ mini_portile (~> 0.6.0)
95
95
  oauth2 (0.9.4)
96
96
  faraday (>= 0.8, < 0.10)
97
97
  jwt (~> 1.0)
@@ -114,54 +114,53 @@ GEM
114
114
  optionable (0.2.0)
115
115
  origin (2.1.1)
116
116
  orm_adapter (0.5.0)
117
- rack (1.6.0.beta)
117
+ rack (1.6.0)
118
118
  rack-openid (1.3.1)
119
119
  rack (>= 1.1.0)
120
120
  ruby-openid (>= 2.1.8)
121
- rack-test (0.6.2)
121
+ rack-test (0.6.3)
122
122
  rack (>= 1.0)
123
- rails (4.2.0.beta2)
124
- actionmailer (= 4.2.0.beta2)
125
- actionpack (= 4.2.0.beta2)
126
- actionview (= 4.2.0.beta2)
127
- activejob (= 4.2.0.beta2)
128
- activemodel (= 4.2.0.beta2)
129
- activerecord (= 4.2.0.beta2)
130
- activesupport (= 4.2.0.beta2)
123
+ rails (4.2.1)
124
+ actionmailer (= 4.2.1)
125
+ actionpack (= 4.2.1)
126
+ actionview (= 4.2.1)
127
+ activejob (= 4.2.1)
128
+ activemodel (= 4.2.1)
129
+ activerecord (= 4.2.1)
130
+ activesupport (= 4.2.1)
131
131
  bundler (>= 1.3.0, < 2.0)
132
- railties (= 4.2.0.beta2)
133
- sprockets-rails (~> 3.0.0.beta1)
132
+ railties (= 4.2.1)
133
+ sprockets-rails
134
134
  rails-deprecated_sanitizer (1.0.3)
135
135
  activesupport (>= 4.2.0.alpha)
136
- rails-dom-testing (1.0.3)
137
- activesupport
136
+ rails-dom-testing (1.0.6)
137
+ activesupport (>= 4.2.0.beta, < 5.0)
138
138
  nokogiri (~> 1.6.0)
139
139
  rails-deprecated_sanitizer (>= 1.0.1)
140
- rails-html-sanitizer (1.0.1)
140
+ rails-html-sanitizer (1.0.2)
141
141
  loofah (~> 2.0)
142
- railties (4.2.0.beta2)
143
- actionpack (= 4.2.0.beta2)
144
- activesupport (= 4.2.0.beta2)
142
+ railties (4.2.1)
143
+ actionpack (= 4.2.1)
144
+ activesupport (= 4.2.1)
145
145
  rake (>= 0.8.7)
146
146
  thor (>= 0.18.1, < 2.0)
147
- rake (10.3.2)
148
- rdoc (4.1.1)
149
- json (~> 1.4)
150
- responders (2.0.0)
151
- railties (>= 4.2.0.alpha, < 5)
152
- ruby-openid (2.5.0)
153
- sprockets (2.12.2)
147
+ rake (10.4.2)
148
+ rdoc (4.2.0)
149
+ responders (2.1.0)
150
+ railties (>= 4.2.0, < 5)
151
+ ruby-openid (2.7.0)
152
+ sprockets (2.12.3)
154
153
  hike (~> 1.2)
155
154
  multi_json (~> 1.0)
156
155
  rack (~> 1.0)
157
156
  tilt (~> 1.1, != 1.3.0)
158
- sprockets-rails (3.0.0.beta1)
159
- actionpack (>= 4.0)
160
- activesupport (>= 4.0)
161
- sprockets (~> 2.8)
162
- sqlite3 (1.3.9)
157
+ sprockets-rails (2.2.4)
158
+ actionpack (>= 3.0)
159
+ activesupport (>= 3.0)
160
+ sprockets (>= 2.8, < 4.0)
161
+ sqlite3 (1.3.10)
163
162
  thor (0.19.1)
164
- thread_safe (0.3.4)
163
+ thread_safe (0.3.5)
165
164
  tilt (1.4.1)
166
165
  tzinfo (1.2.2)
167
166
  thread_safe (~> 0.1)
@@ -186,7 +185,7 @@ DEPENDENCIES
186
185
  omniauth-facebook
187
186
  omniauth-oauth2 (~> 1.1.0)
188
187
  omniauth-openid (~> 1.0.1)
189
- rails (= 4.2.0.beta2)
188
+ rails (= 4.2.1)
190
189
  rdoc
191
190
  sqlite3
192
191
  webrat (= 0.7.3)
@@ -1,4 +1,4 @@
1
- Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
1
+ Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  By [Plataformatec](http://plataformatec.com.br/).
4
4
 
5
- [![Build Status](https://api.travis-ci.org/plataformatec/devise.png?branch=master)](http://travis-ci.org/plataformatec/devise)
6
- [![Code Climate](https://codeclimate.com/github/plataformatec/devise.png)](https://codeclimate.com/github/plataformatec/devise)
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
7
  [![Security](https://hakiri.io/github/plataformatec/devise/master.svg)](https://hakiri.io/github/plataformatec/devise/master)
8
8
 
9
9
  This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
@@ -13,18 +13,18 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
13
13
  * Is Rack based;
14
14
  * Is a complete MVC solution based on Rails engines;
15
15
  * Allows you to have multiple models signed in at the same time;
16
- * Is based on a modularity concept: use just what you really need.
16
+ * Is based on a modularity concept: use only what you really need.
17
17
 
18
18
  It's composed of 10 modules:
19
19
 
20
20
  * [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
- * [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds Omniauth (https://github.com/intridea/omniauth) support.
21
+ * [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/intridea/omniauth) support.
22
22
  * [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.
23
23
  * [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
24
24
  * [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.
25
25
  * [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
26
26
  * [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
27
- * [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have no activity in a specified period of time.
27
+ * [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
28
28
  * [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.
29
29
  * [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.
30
30
 
@@ -44,7 +44,7 @@ If you discover a problem with Devise, we would like to know about it. However,
44
44
 
45
45
  https://github.com/plataformatec/devise/wiki/Bug-reports
46
46
 
47
- If you found a security bug, do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
47
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
48
48
 
49
49
  ### Mailing list
50
50
 
@@ -82,12 +82,12 @@ You will usually want to write tests for your changes. To run the test suite, g
82
82
 
83
83
  ## Starting with Rails?
84
84
 
85
- If you are building your first Rails application, we recommend you to *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 two resources:
85
+ 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 two resources that should help you get started:
86
86
 
87
- * Michael Hartl's online book: http://www.railstutorial.org/book/demo_app#sec-modeling_demo_users
87
+ * Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
88
88
  * Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
89
89
 
90
- Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
90
+ Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
91
91
 
92
92
  ## Getting started
93
93
 
@@ -105,7 +105,7 @@ After you install Devise and add it to your Gemfile, you need to run the generat
105
105
  rails generate devise:install
106
106
  ```
107
107
 
108
- The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
108
+ The generator will install an initializer which describes ALL of Devise's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
109
109
 
110
110
  ```console
111
111
  rails generate devise MODEL
@@ -121,7 +121,7 @@ Next, you need to set up the default URL options for the Devise mailer in each e
121
121
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
122
122
  ```
123
123
 
124
- You should restart your application after changing Devise's configuration options. Otherwise you'll run into strange errors like users being unable to login and route helpers being undefined.
124
+ 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.
125
125
 
126
126
  ### Controller filters and helpers
127
127
 
@@ -151,7 +151,7 @@ You can access the session for this scope:
151
151
  user_session
152
152
  ```
153
153
 
154
- After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect. For instance, for a `:user` resource, the `user_root_path` will be used if it exists, otherwise the default `root_path` will be used. This means that you need to set the root inside your routes:
154
+ After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect to. For instance, when using a `:user` resource, the `user_root_path` will be used if it exists; otherwise, the default `root_path` will be used. This means that you need to set the root inside your routes:
155
155
 
156
156
  ```ruby
157
157
  root to: "home#index"
@@ -179,7 +179,7 @@ The Devise method in your models also accepts some options to configure its modu
179
179
  devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
180
180
  ```
181
181
 
182
- 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.
182
+ 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`.
183
183
 
184
184
  ### Strong Parameters
185
185
 
@@ -191,7 +191,7 @@ There are just three actions in Devise that allows any set of parameters to be p
191
191
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
192
192
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
193
193
 
194
- In case you want to permit additional parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
194
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
195
195
 
196
196
  ```ruby
197
197
  class ApplicationController < ActionController::Base
@@ -215,7 +215,7 @@ def configure_permitted_parameters
215
215
  end
216
216
  ```
217
217
 
218
- If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters permitted scalars, so we need to configure Devise thusly:
218
+ If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters' permitted scalars, so we need to configure Devise in the following way:
219
219
 
220
220
  ```ruby
221
221
  def configure_permitted_parameters
@@ -226,7 +226,7 @@ For the list of permitted scalars, and how to declare permitted keys in nested h
226
226
 
227
227
  https://github.com/rails/strong_parameters#nested-parameters
228
228
 
229
- 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:
229
+ If you have multiple Devise models, you may want to set up a different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and adding your own logic:
230
230
 
231
231
  ```ruby
232
232
  class User::ParameterSanitizer < Devise::ParameterSanitizer
@@ -272,7 +272,7 @@ After doing so, you will be able to have views based on the role like `users/ses
272
272
  rails generate devise:views users
273
273
  ```
274
274
 
275
- If you want to generate only a few set of views, like the ones for the `registrable` and `confirmable` module,
275
+ If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
276
276
  you can pass a list of modules to the generator with the `-v` flag.
277
277
 
278
278
  ```console
@@ -336,7 +336,7 @@ If the customization at the views level is not enough, you can customize each co
336
336
 
337
337
  This is useful for triggering background jobs or logging events during certain actions.
338
338
 
339
- Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
339
+ Remember that Devise uses flash messages to let users know if sign in was successful or unsuccessful. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
340
340
 
341
341
  ### Configuring routes
342
342
 
@@ -356,11 +356,11 @@ devise_scope :user do
356
356
  end
357
357
  ```
358
358
 
359
- 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.
359
+ 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.
360
360
 
361
361
  ### I18n
362
362
 
363
- Devise uses flash messages with I18n with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
363
+ 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:
364
364
 
365
365
  ```yaml
366
366
  en:
@@ -398,7 +398,7 @@ Take a look at our locale file to check all available messages. You may also be
398
398
 
399
399
  https://github.com/plataformatec/devise/wiki/I18n
400
400
 
401
- Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController
401
+ Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
402
402
 
403
403
  ### Test helpers
404
404
 
@@ -418,6 +418,8 @@ RSpec.configure do |config|
418
418
  end
419
419
  ```
420
420
 
421
+ Just be sure that this inclusion is made *after* the `require 'rspec/rails'` directive.
422
+
421
423
  Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
422
424
 
423
425
  ```ruby
@@ -432,22 +434,26 @@ There are two things that are important to keep in mind:
432
434
 
433
435
  1. These helpers are not going to work for integration tests driven by Capybara or Webrat. They are meant to be used with functional tests only. Instead, fill in the form or explicitly set the user in session;
434
436
 
435
- 2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from the router, but since functional tests do not pass through the router, it needs to be told explicitly. For example, if you are testing the user scope, simply do:
437
+ 2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from the router, but since functional tests do not pass through the router, it needs to be stated explicitly. For example, if you are testing the user scope, simply use:
436
438
 
437
439
  ```ruby
438
440
  @request.env["devise.mapping"] = Devise.mappings[:user]
439
441
  get :new
440
442
  ```
441
443
 
442
- ### Omniauth
444
+ You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
445
+
446
+ * https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
447
+
448
+ ### OmniAuth
443
449
 
444
- Devise comes with Omniauth support out of the box to authenticate with other providers. To use it, just specify your omniauth configuration in `config/initializers/devise.rb`:
450
+ Devise comes with OmniAuth support out of the box to authenticate with other providers. To use it, simply specify your OmniAuth configuration in `config/initializers/devise.rb`:
445
451
 
446
452
  ```ruby
447
453
  config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
448
454
  ```
449
455
 
450
- You can read more about Omniauth support in the wiki:
456
+ You can read more about OmniAuth support in the wiki:
451
457
 
452
458
  * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
453
459
 
@@ -460,7 +466,7 @@ Devise allows you to set up as many Devise models as you want. If you want to ha
460
466
  create_table :admins do |t|
461
467
  t.string :email
462
468
  t.string :encrypted_password
463
- t.timestamps
469
+ t.timestamps null: false
464
470
  end
465
471
 
466
472
  # Inside your Admin model
@@ -480,12 +486,12 @@ admin_session
480
486
 
481
487
  Alternatively, you can simply run the Devise generator.
482
488
 
483
- 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 a dedicated gem for authorization.
489
+ 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 that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
484
490
 
485
491
  ### ActiveJob Integration
486
492
 
487
493
  If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
488
- background through a queueing backend, you can send Devise emails through your
494
+ background through a queuing back-end, you can send Devise emails through your
489
495
  existing queue by overriding the `send_devise_notification` method in your model.
490
496
 
491
497
  ```ruby
@@ -494,15 +500,29 @@ def send_devise_notification(notification, *args)
494
500
  end
495
501
  ```
496
502
 
503
+ ### Password reset tokens and Rails logs
504
+
505
+ 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:
506
+
507
+ 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.
508
+ 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.
509
+
510
+ 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`:
511
+
512
+ ```ruby
513
+ config.log_level = :warn
514
+ ```
515
+
516
+
497
517
  ### Other ORMs
498
518
 
499
- Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
519
+ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
500
520
 
501
521
  ## Additional information
502
522
 
503
523
  ### Heroku
504
524
 
505
- Using Devise on Heroku with Ruby on Rails 3.1 requires setting:
525
+ Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
506
526
 
507
527
  ```ruby
508
528
  config.assets.initialize_on_precompile = false
@@ -524,6 +544,6 @@ https://github.com/plataformatec/devise/graphs/contributors
524
544
 
525
545
  ## License
526
546
 
527
- MIT License. Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
547
+ MIT License. Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
528
548
 
529
- You are not granted rights or licenses to the trademarks of the Plataformatec, including without limitation the Devise name or logo.
549
+ You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.