devise 3.4.1 → 3.5.10

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +28 -19
  3. data/CHANGELOG.md +193 -104
  4. data/CODE_OF_CONDUCT.md +22 -0
  5. data/CONTRIBUTING.md +2 -0
  6. data/Gemfile +3 -2
  7. data/Gemfile.lock +90 -95
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +55 -34
  10. data/Rakefile +2 -1
  11. data/app/controllers/devise/confirmations_controller.rb +4 -0
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +4 -0
  13. data/app/controllers/devise/passwords_controller.rb +14 -4
  14. data/app/controllers/devise/registrations_controller.rb +10 -11
  15. data/app/controllers/devise/sessions_controller.rb +7 -2
  16. data/app/controllers/devise/unlocks_controller.rb +3 -0
  17. data/app/controllers/devise_controller.rb +34 -18
  18. data/app/mailers/devise/mailer.rb +4 -0
  19. data/app/views/devise/confirmations/new.html.erb +1 -1
  20. data/app/views/devise/mailer/password_change.html.erb +3 -0
  21. data/app/views/devise/passwords/edit.html.erb +3 -0
  22. data/app/views/devise/registrations/new.html.erb +1 -1
  23. data/app/views/devise/shared/_links.html.erb +1 -1
  24. data/config/locales/en.yml +2 -0
  25. data/devise.gemspec +0 -2
  26. data/gemfiles/Gemfile.rails-3.2-stable.lock +52 -49
  27. data/gemfiles/Gemfile.rails-4.0-stable +1 -0
  28. data/gemfiles/Gemfile.rails-4.0-stable.lock +61 -60
  29. data/gemfiles/Gemfile.rails-4.1-stable +1 -0
  30. data/gemfiles/Gemfile.rails-4.1-stable.lock +66 -65
  31. data/gemfiles/Gemfile.rails-4.2-stable +30 -0
  32. data/gemfiles/Gemfile.rails-4.2-stable.lock +193 -0
  33. data/lib/devise/controllers/helpers.rb +12 -6
  34. data/lib/devise/controllers/rememberable.rb +9 -2
  35. data/lib/devise/controllers/sign_in_out.rb +2 -8
  36. data/lib/devise/controllers/store_location.rb +3 -1
  37. data/lib/devise/controllers/url_helpers.rb +7 -9
  38. data/lib/devise/encryptor.rb +22 -0
  39. data/lib/devise/failure_app.rb +48 -13
  40. data/lib/devise/hooks/timeoutable.rb +5 -7
  41. data/lib/devise/mapping.rb +1 -0
  42. data/lib/devise/models/authenticatable.rb +20 -26
  43. data/lib/devise/models/confirmable.rb +51 -17
  44. data/lib/devise/models/database_authenticatable.rb +17 -11
  45. data/lib/devise/models/lockable.rb +5 -1
  46. data/lib/devise/models/recoverable.rb +23 -15
  47. data/lib/devise/models/rememberable.rb +56 -22
  48. data/lib/devise/models/timeoutable.rb +0 -6
  49. data/lib/devise/models/trackable.rb +1 -2
  50. data/lib/devise/models/validatable.rb +3 -3
  51. data/lib/devise/models.rb +1 -1
  52. data/lib/devise/rails/routes.rb +27 -18
  53. data/lib/devise/rails.rb +1 -1
  54. data/lib/devise/strategies/authenticatable.rb +7 -4
  55. data/lib/devise/strategies/database_authenticatable.rb +1 -1
  56. data/lib/devise/strategies/rememberable.rb +13 -6
  57. data/lib/devise/test_helpers.rb +2 -2
  58. data/lib/devise/version.rb +1 -1
  59. data/lib/devise.rb +37 -36
  60. data/lib/generators/active_record/templates/migration.rb +1 -1
  61. data/lib/generators/active_record/templates/migration_existing.rb +1 -1
  62. data/lib/generators/devise/views_generator.rb +14 -3
  63. data/lib/generators/templates/controllers/README +2 -2
  64. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  65. data/lib/generators/templates/controllers/registrations_controller.rb +2 -2
  66. data/lib/generators/templates/controllers/sessions_controller.rb +1 -1
  67. data/lib/generators/templates/devise.rb +17 -11
  68. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  69. data/lib/generators/templates/markerb/password_change.markerb +3 -0
  70. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  71. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  72. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +1 -1
  73. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
  74. data/test/controllers/custom_registrations_controller_test.rb +6 -1
  75. data/test/controllers/helper_methods_test.rb +21 -0
  76. data/test/controllers/helpers_test.rb +5 -0
  77. data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
  78. data/test/controllers/internal_helpers_test.rb +4 -4
  79. data/test/controllers/load_hooks_controller_test.rb +19 -0
  80. data/test/controllers/passwords_controller_test.rb +1 -1
  81. data/test/controllers/sessions_controller_test.rb +3 -3
  82. data/test/devise_test.rb +3 -3
  83. data/test/failure_app_test.rb +40 -0
  84. data/test/generators/views_generator_test.rb +7 -0
  85. data/test/integration/database_authenticatable_test.rb +11 -0
  86. data/test/integration/omniauthable_test.rb +12 -10
  87. data/test/integration/recoverable_test.rb +13 -0
  88. data/test/integration/rememberable_test.rb +50 -3
  89. data/test/integration/timeoutable_test.rb +13 -18
  90. data/test/mailers/confirmation_instructions_test.rb +1 -1
  91. data/test/mapping_test.rb +6 -0
  92. data/test/models/confirmable_test.rb +93 -37
  93. data/test/models/database_authenticatable_test.rb +20 -0
  94. data/test/models/lockable_test.rb +29 -7
  95. data/test/models/recoverable_test.rb +62 -7
  96. data/test/models/rememberable_test.rb +68 -97
  97. data/test/models/validatable_test.rb +5 -5
  98. data/test/models_test.rb +15 -6
  99. data/test/rails_app/app/active_record/user_without_email.rb +8 -0
  100. data/test/rails_app/app/controllers/admins_controller.rb +0 -5
  101. data/test/rails_app/app/controllers/custom/registrations_controller.rb +10 -0
  102. data/test/rails_app/app/mongoid/user_without_email.rb +33 -0
  103. data/test/rails_app/config/application.rb +1 -1
  104. data/test/rails_app/config/environments/production.rb +6 -2
  105. data/test/rails_app/config/environments/test.rb +7 -2
  106. data/test/rails_app/config/initializers/devise.rb +12 -15
  107. data/test/rails_app/config/routes.rb +6 -3
  108. data/test/rails_app/lib/shared_user.rb +1 -1
  109. data/test/rails_app/lib/shared_user_without_email.rb +26 -0
  110. data/test/rails_test.rb +9 -0
  111. data/test/support/helpers.rb +4 -0
  112. data/test/support/integration.rb +2 -2
  113. data/test/test_helpers_test.rb +22 -7
  114. data/test/test_models.rb +2 -2
  115. data/test/time_helpers.rb +137 -0
  116. metadata +26 -4
@@ -0,0 +1,22 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
6
+
7
+ Examples of unacceptable behavior by participants include:
8
+
9
+ * The use of sexualized language or imagery
10
+ * Personal attacks
11
+ * Trolling or insulting/derogatory comments
12
+ * Public or private harassment
13
+ * Publishing other's private information, such as physical or electronic addresses, without explicit permission
14
+ * Other unethical or unprofessional conduct.
15
+
16
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17
+
18
+ This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
19
+
20
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by sending an email to [conduct@plataformatec.com.br](conduct@plataformatec.com.br) or contacting one or more of the project maintainers.
21
+
22
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
data/CONTRIBUTING.md CHANGED
@@ -8,6 +8,8 @@
8
8
 
9
9
  4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
10
10
 
11
+ 5) Notice that all of your interactions in the project are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md)
12
+
11
13
  That's it! The more information you give, the easier it becomes for us to track it down and fix it.
12
14
  Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
13
15
 
data/Gemfile CHANGED
@@ -2,10 +2,11 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "4.2.0.beta2"
5
+ gem "rails", "4.2.2"
6
6
  gem "omniauth", "~> 1.2.0"
7
7
  gem "omniauth-oauth2", "~> 1.1.0"
8
8
  gem "rdoc"
9
+ gem "mime-types", "~> 2.99"
9
10
 
10
11
  group :test do
11
12
  gem "omniauth-facebook"
@@ -25,5 +26,5 @@ platforms :ruby do
25
26
  end
26
27
 
27
28
  group :mongoid do
28
- gem "mongoid", github: "mongoid/mongoid", branch: "master"
29
+ gem "mongoid", "~> 4.0"
29
30
  end
data/Gemfile.lock CHANGED
@@ -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.10)
16
5
  bcrypt (~> 3.0)
17
6
  orm_adapter (~> 0.1)
18
7
  railties (>= 3.2.6, < 5)
@@ -23,75 +12,80 @@ PATH
23
12
  GEM
24
13
  remote: https://rubygems.org/
25
14
  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)
15
+ actionmailer (4.2.2)
16
+ actionpack (= 4.2.2)
17
+ actionview (= 4.2.2)
18
+ activejob (= 4.2.2)
30
19
  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)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ actionpack (4.2.2)
22
+ actionview (= 4.2.2)
23
+ activesupport (= 4.2.2)
24
+ rack (~> 1.6)
36
25
  rack-test (~> 0.6.2)
37
- rails-dom-testing (~> 1.0, >= 1.0.3)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
38
27
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
39
- actionview (4.2.0.beta2)
40
- activesupport (= 4.2.0.beta2)
28
+ actionview (4.2.2)
29
+ activesupport (= 4.2.2)
41
30
  builder (~> 3.1)
42
31
  erubis (~> 2.7.0)
43
- rails-dom-testing (~> 1.0, >= 1.0.3)
32
+ rails-dom-testing (~> 1.0, >= 1.0.5)
44
33
  rails-html-sanitizer (~> 1.0, >= 1.0.1)
45
- activejob (4.2.0.beta2)
46
- activesupport (= 4.2.0.beta2)
34
+ activejob (4.2.2)
35
+ activesupport (= 4.2.2)
47
36
  globalid (>= 0.3.0)
48
- activemodel (4.2.0.beta2)
49
- activesupport (= 4.2.0.beta2)
37
+ activemodel (4.2.2)
38
+ activesupport (= 4.2.2)
50
39
  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)
40
+ activerecord (4.2.2)
41
+ activemodel (= 4.2.2)
42
+ activesupport (= 4.2.2)
43
+ arel (~> 6.0)
44
+ activesupport (4.2.2)
45
+ i18n (~> 0.7)
57
46
  json (~> 1.7, >= 1.7.7)
58
47
  minitest (~> 5.1)
59
- thread_safe (~> 0.1)
48
+ thread_safe (~> 0.3, >= 0.3.4)
60
49
  tzinfo (~> 1.1)
61
- arel (6.0.0.beta1)
62
- bcrypt (3.1.7)
63
- bson (2.3.0)
50
+ arel (6.0.3)
51
+ bcrypt (3.1.11)
52
+ bson (3.2.6)
64
53
  builder (3.2.2)
65
- connection_pool (2.0.0)
54
+ concurrent-ruby (1.0.1)
55
+ connection_pool (2.2.0)
66
56
  erubis (2.7.0)
67
- faraday (0.9.0)
57
+ faraday (0.9.2)
68
58
  multipart-post (>= 1.2, < 3)
69
- globalid (0.3.0)
59
+ globalid (0.3.6)
70
60
  activesupport (>= 4.1.0)
71
- hashie (3.2.0)
72
- hike (1.2.3)
73
- i18n (0.7.0.beta1)
74
- json (1.8.1)
75
- jwt (1.0.0)
76
- loofah (2.0.1)
61
+ hashie (3.4.3)
62
+ i18n (0.7.0)
63
+ json (1.8.3)
64
+ jwt (1.5.4)
65
+ loofah (2.0.3)
77
66
  nokogiri (>= 1.5.9)
78
- mail (2.6.1)
79
- mime-types (>= 1.16, < 3)
67
+ mail (2.6.4)
68
+ mime-types (>= 1.16, < 4)
80
69
  metaclass (0.0.4)
81
- mime-types (2.3)
82
- mini_portile (0.6.0)
83
- minitest (5.4.2)
70
+ mime-types (2.99.1)
71
+ mini_portile2 (2.0.0)
72
+ minitest (5.8.4)
84
73
  mocha (1.1.0)
85
74
  metaclass (~> 0.0.1)
86
- moped (2.0.0)
87
- bson (~> 2.2)
75
+ mongoid (4.0.2)
76
+ activemodel (~> 4.0)
77
+ moped (~> 2.0.0)
78
+ origin (~> 2.1)
79
+ tzinfo (>= 0.3.37)
80
+ moped (2.0.7)
81
+ bson (~> 3.0)
88
82
  connection_pool (~> 2.0)
89
83
  optionable (~> 0.2.0)
90
- multi_json (1.10.1)
84
+ multi_json (1.11.3)
91
85
  multi_xml (0.5.5)
92
86
  multipart-post (2.0.0)
93
- nokogiri (1.6.3.1)
94
- mini_portile (= 0.6.0)
87
+ nokogiri (1.6.7.2)
88
+ mini_portile2 (~> 2.0.0.rc2)
95
89
  oauth2 (0.9.4)
96
90
  faraday (>= 0.8, < 0.10)
97
91
  jwt (~> 1.0)
@@ -112,60 +106,57 @@ GEM
112
106
  omniauth (~> 1.0)
113
107
  rack-openid (~> 1.3.1)
114
108
  optionable (0.2.0)
115
- origin (2.1.1)
109
+ origin (2.2.0)
116
110
  orm_adapter (0.5.0)
117
- rack (1.6.0.beta)
111
+ rack (1.6.4)
118
112
  rack-openid (1.3.1)
119
113
  rack (>= 1.1.0)
120
114
  ruby-openid (>= 2.1.8)
121
- rack-test (0.6.2)
115
+ rack-test (0.6.3)
122
116
  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)
117
+ rails (4.2.2)
118
+ actionmailer (= 4.2.2)
119
+ actionpack (= 4.2.2)
120
+ actionview (= 4.2.2)
121
+ activejob (= 4.2.2)
122
+ activemodel (= 4.2.2)
123
+ activerecord (= 4.2.2)
124
+ activesupport (= 4.2.2)
131
125
  bundler (>= 1.3.0, < 2.0)
132
- railties (= 4.2.0.beta2)
133
- sprockets-rails (~> 3.0.0.beta1)
126
+ railties (= 4.2.2)
127
+ sprockets-rails
134
128
  rails-deprecated_sanitizer (1.0.3)
135
129
  activesupport (>= 4.2.0.alpha)
136
- rails-dom-testing (1.0.3)
137
- activesupport
130
+ rails-dom-testing (1.0.7)
131
+ activesupport (>= 4.2.0.beta, < 5.0)
138
132
  nokogiri (~> 1.6.0)
139
133
  rails-deprecated_sanitizer (>= 1.0.1)
140
- rails-html-sanitizer (1.0.1)
134
+ rails-html-sanitizer (1.0.3)
141
135
  loofah (~> 2.0)
142
- railties (4.2.0.beta2)
143
- actionpack (= 4.2.0.beta2)
144
- activesupport (= 4.2.0.beta2)
136
+ railties (4.2.2)
137
+ actionpack (= 4.2.2)
138
+ activesupport (= 4.2.2)
145
139
  rake (>= 0.8.7)
146
140
  thor (>= 0.18.1, < 2.0)
147
- rake (10.3.2)
148
- rdoc (4.1.1)
141
+ rake (11.1.2)
142
+ rdoc (4.2.2)
149
143
  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)
154
- hike (~> 1.2)
155
- multi_json (~> 1.0)
156
- rack (~> 1.0)
157
- tilt (~> 1.1, != 1.3.0)
158
- sprockets-rails (3.0.0.beta1)
144
+ responders (2.2.0)
145
+ railties (>= 4.2.0, < 5.1)
146
+ ruby-openid (2.7.0)
147
+ sprockets (3.6.0)
148
+ concurrent-ruby (~> 1.0)
149
+ rack (> 1, < 3)
150
+ sprockets-rails (3.0.4)
159
151
  actionpack (>= 4.0)
160
152
  activesupport (>= 4.0)
161
- sprockets (~> 2.8)
162
- sqlite3 (1.3.9)
153
+ sprockets (>= 3.0.0)
154
+ sqlite3 (1.3.11)
163
155
  thor (0.19.1)
164
- thread_safe (0.3.4)
165
- tilt (1.4.1)
156
+ thread_safe (0.3.5)
166
157
  tzinfo (1.2.2)
167
158
  thread_safe (~> 0.1)
168
- warden (1.2.3)
159
+ warden (1.2.6)
169
160
  rack (>= 1.0)
170
161
  webrat (0.7.3)
171
162
  nokogiri (>= 1.2.0)
@@ -180,13 +171,17 @@ DEPENDENCIES
180
171
  activerecord-jdbcsqlite3-adapter
181
172
  devise!
182
173
  jruby-openssl
174
+ mime-types (~> 2.99)
183
175
  mocha (~> 1.1)
184
- mongoid!
176
+ mongoid (~> 4.0)
185
177
  omniauth (~> 1.2.0)
186
178
  omniauth-facebook
187
179
  omniauth-oauth2 (~> 1.1.0)
188
180
  omniauth-openid (~> 1.0.1)
189
- rails (= 4.2.0.beta2)
181
+ rails (= 4.2.2)
190
182
  rdoc
191
183
  sqlite3
192
184
  webrat (= 0.7.3)
185
+
186
+ BUNDLED WITH
187
+ 1.12.3
data/MIT-LICENSE CHANGED
@@ -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,13 @@ 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 three 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
+ * Codecademy's Ruby on Rails: Authentication and Authorization: http://www.codecademy.com/en/learn/rails-auth
89
90
 
90
- Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :)
91
+ Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
91
92
 
92
93
  ## Getting started
93
94
 
@@ -105,7 +106,7 @@ After you install Devise and add it to your Gemfile, you need to run the generat
105
106
  rails generate devise:install
106
107
  ```
107
108
 
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:
109
+ 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
110
 
110
111
  ```console
111
112
  rails generate devise MODEL
@@ -121,7 +122,7 @@ Next, you need to set up the default URL options for the Devise mailer in each e
121
122
  config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
122
123
  ```
123
124
 
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.
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.
125
126
 
126
127
  ### Controller filters and helpers
127
128
 
@@ -151,7 +152,7 @@ You can access the session for this scope:
151
152
  user_session
152
153
  ```
153
154
 
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:
155
+ 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
156
 
156
157
  ```ruby
157
158
  root to: "home#index"
@@ -179,19 +180,19 @@ The Devise method in your models also accepts some options to configure its modu
179
180
  devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
180
181
  ```
181
182
 
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.
183
+ 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
184
 
184
185
  ### Strong Parameters
185
186
 
186
187
  When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
187
188
 
188
- There are just three actions in Devise that allows any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
189
+ There are just three actions in Devise that allow any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
189
190
 
190
191
  * `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
191
192
  * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
192
193
  * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
193
194
 
194
- In case you want to permit additional parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
195
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
195
196
 
196
197
  ```ruby
197
198
  class ApplicationController < ActionController::Base
@@ -215,7 +216,7 @@ def configure_permitted_parameters
215
216
  end
216
217
  ```
217
218
 
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:
219
+ 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
220
 
220
221
  ```ruby
221
222
  def configure_permitted_parameters
@@ -226,7 +227,7 @@ For the list of permitted scalars, and how to declare permitted keys in nested h
226
227
 
227
228
  https://github.com/rails/strong_parameters#nested-parameters
228
229
 
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:
230
+ 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
231
 
231
232
  ```ruby
232
233
  class User::ParameterSanitizer < Devise::ParameterSanitizer
@@ -272,7 +273,7 @@ After doing so, you will be able to have views based on the role like `users/ses
272
273
  rails generate devise:views users
273
274
  ```
274
275
 
275
- If you want to generate only a few set of views, like the ones for the `registrable` and `confirmable` module,
276
+ If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
276
277
  you can pass a list of modules to the generator with the `-v` flag.
277
278
 
278
279
  ```console
@@ -336,7 +337,7 @@ If the customization at the views level is not enough, you can customize each co
336
337
 
337
338
  This is useful for triggering background jobs or logging events during certain actions.
338
339
 
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.
340
+ 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
341
 
341
342
  ### Configuring routes
342
343
 
@@ -348,7 +349,7 @@ devise_for :users, path: "auth", path_names: { sign_in: 'login', sign_out: 'logo
348
349
 
349
350
  Be sure to check `devise_for` documentation for details.
350
351
 
351
- If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is to create your routes normally and wrap them in a `devise_scope` block in the router:
352
+ If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
352
353
 
353
354
  ```ruby
354
355
  devise_scope :user do
@@ -356,11 +357,11 @@ devise_scope :user do
356
357
  end
357
358
  ```
358
359
 
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
+ 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
361
 
361
362
  ### I18n
362
363
 
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:
364
+ 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
365
 
365
366
  ```yaml
366
367
  en:
@@ -398,7 +399,7 @@ Take a look at our locale file to check all available messages. You may also be
398
399
 
399
400
  https://github.com/plataformatec/devise/wiki/I18n
400
401
 
401
- Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController
402
+ Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
402
403
 
403
404
  ### Test helpers
404
405
 
@@ -418,6 +419,8 @@ RSpec.configure do |config|
418
419
  end
419
420
  ```
420
421
 
422
+ Just be sure that this inclusion is made *after* the `require 'rspec/rails'` directive.
423
+
421
424
  Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
422
425
 
423
426
  ```ruby
@@ -432,22 +435,26 @@ There are two things that are important to keep in mind:
432
435
 
433
436
  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
437
 
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:
438
+ 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
439
 
437
440
  ```ruby
438
441
  @request.env["devise.mapping"] = Devise.mappings[:user]
439
442
  get :new
440
443
  ```
441
444
 
442
- ### Omniauth
445
+ You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
446
+
447
+ * https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29
448
+
449
+ ### OmniAuth
443
450
 
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`:
451
+ 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
452
 
446
453
  ```ruby
447
454
  config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
448
455
  ```
449
456
 
450
- You can read more about Omniauth support in the wiki:
457
+ You can read more about OmniAuth support in the wiki:
451
458
 
452
459
  * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
453
460
 
@@ -460,7 +467,7 @@ Devise allows you to set up as many Devise models as you want. If you want to ha
460
467
  create_table :admins do |t|
461
468
  t.string :email
462
469
  t.string :encrypted_password
463
- t.timestamps
470
+ t.timestamps null: false
464
471
  end
465
472
 
466
473
  # Inside your Admin model
@@ -480,12 +487,12 @@ admin_session
480
487
 
481
488
  Alternatively, you can simply run the Devise generator.
482
489
 
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.
490
+ 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
491
 
485
492
  ### ActiveJob Integration
486
493
 
487
494
  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
495
+ background through a queuing back-end, you can send Devise emails through your
489
496
  existing queue by overriding the `send_devise_notification` method in your model.
490
497
 
491
498
  ```ruby
@@ -494,15 +501,29 @@ def send_devise_notification(notification, *args)
494
501
  end
495
502
  ```
496
503
 
504
+ ### Password reset tokens and Rails logs
505
+
506
+ 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:
507
+
508
+ 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.
509
+ 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.
510
+
511
+ 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`:
512
+
513
+ ```ruby
514
+ config.log_level = :warn
515
+ ```
516
+
517
+
497
518
  ### Other ORMs
498
519
 
499
- Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
520
+ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
500
521
 
501
522
  ## Additional information
502
523
 
503
524
  ### Heroku
504
525
 
505
- Using Devise on Heroku with Ruby on Rails 3.1 requires setting:
526
+ Using Devise on Heroku with Ruby on Rails 3.2 requires setting:
506
527
 
507
528
  ```ruby
508
529
  config.assets.initialize_on_precompile = false
@@ -524,6 +545,6 @@ https://github.com/plataformatec/devise/graphs/contributors
524
545
 
525
546
  ## License
526
547
 
527
- MIT License. Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
548
+ MIT License. Copyright 2009-2015 Plataformatec. http://plataformatec.com.br
528
549
 
529
- You are not granted rights or licenses to the trademarks of the Plataformatec, including without limitation the Devise name or logo.
550
+ You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  # encoding: UTF-8
2
- require "bundler/gem_tasks"
2
+
3
+ require 'bundler/gem_tasks'
3
4
  require 'rake/testtask'
4
5
  require 'rdoc/task'
5
6
 
@@ -44,4 +44,8 @@ class Devise::ConfirmationsController < DeviseController
44
44
  new_session_path(resource_name)
45
45
  end
46
46
  end
47
+
48
+ def translation_scope
49
+ 'devise.confirmations'
50
+ end
47
51
  end
@@ -27,4 +27,8 @@ class Devise::OmniauthCallbacksController < DeviseController
27
27
  def after_omniauth_failure_path_for(scope)
28
28
  new_session_path(scope)
29
29
  end
30
+
31
+ def translation_scope
32
+ 'devise.omniauth_callbacks'
33
+ end
30
34
  end