devise 4.3.0 → 4.4.2

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 (217) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +15 -5
  3. data/CHANGELOG.md +41 -0
  4. data/Gemfile +2 -3
  5. data/Gemfile.lock +3 -4
  6. data/ISSUE_TEMPLATE.md +19 -0
  7. data/README.md +97 -4
  8. data/Rakefile +1 -0
  9. data/app/controllers/devise/confirmations_controller.rb +2 -0
  10. data/app/controllers/devise/omniauth_callbacks_controller.rb +3 -1
  11. data/app/controllers/devise/passwords_controller.rb +2 -0
  12. data/app/controllers/devise/registrations_controller.rb +5 -3
  13. data/app/controllers/devise/sessions_controller.rb +3 -1
  14. data/app/controllers/devise/unlocks_controller.rb +2 -0
  15. data/app/controllers/devise_controller.rb +2 -0
  16. data/app/helpers/devise_helper.rb +2 -0
  17. data/app/mailers/devise/mailer.rb +2 -0
  18. data/app/views/devise/confirmations/new.html.erb +1 -1
  19. data/app/views/devise/passwords/new.html.erb +1 -1
  20. data/app/views/devise/registrations/edit.html.erb +1 -1
  21. data/app/views/devise/registrations/new.html.erb +1 -1
  22. data/app/views/devise/sessions/new.html.erb +1 -1
  23. data/app/views/devise/unlocks/new.html.erb +1 -1
  24. data/devise.gemspec +3 -1
  25. data/gemfiles/Gemfile.rails-4.1-stable +3 -1
  26. data/gemfiles/Gemfile.rails-4.1-stable.lock +4 -4
  27. data/gemfiles/Gemfile.rails-4.2-stable +3 -1
  28. data/gemfiles/Gemfile.rails-4.2-stable.lock +4 -4
  29. data/gemfiles/Gemfile.rails-5.0-stable +2 -3
  30. data/gemfiles/Gemfile.rails-5.0-stable.lock +3 -4
  31. data/gemfiles/Gemfile.rails-5.2-rc1 +26 -0
  32. data/gemfiles/Gemfile.rails-5.2-rc1.lock +201 -0
  33. data/guides/bug_report_templates/integration_test.rb +2 -0
  34. data/lib/devise/controllers/helpers.rb +2 -0
  35. data/lib/devise/controllers/rememberable.rb +2 -0
  36. data/lib/devise/controllers/scoped_views.rb +2 -0
  37. data/lib/devise/controllers/sign_in_out.rb +6 -1
  38. data/lib/devise/controllers/store_location.rb +24 -6
  39. data/lib/devise/controllers/url_helpers.rb +2 -0
  40. data/lib/devise/delegator.rb +2 -0
  41. data/lib/devise/encryptor.rb +2 -0
  42. data/lib/devise/failure_app.rb +2 -0
  43. data/lib/devise/hooks/activatable.rb +2 -0
  44. data/lib/devise/hooks/csrf_cleaner.rb +2 -0
  45. data/lib/devise/hooks/forgetable.rb +2 -0
  46. data/lib/devise/hooks/lockable.rb +2 -0
  47. data/lib/devise/hooks/proxy.rb +2 -0
  48. data/lib/devise/hooks/rememberable.rb +2 -0
  49. data/lib/devise/hooks/timeoutable.rb +2 -0
  50. data/lib/devise/hooks/trackable.rb +2 -0
  51. data/lib/devise/mailers/helpers.rb +2 -0
  52. data/lib/devise/mapping.rb +2 -0
  53. data/lib/devise/models/authenticatable.rb +4 -2
  54. data/lib/devise/models/confirmable.rb +3 -1
  55. data/lib/devise/models/database_authenticatable.rb +3 -1
  56. data/lib/devise/models/lockable.rb +8 -2
  57. data/lib/devise/models/omniauthable.rb +2 -0
  58. data/lib/devise/models/recoverable.rb +2 -0
  59. data/lib/devise/models/registerable.rb +2 -0
  60. data/lib/devise/models/rememberable.rb +3 -1
  61. data/lib/devise/models/timeoutable.rb +2 -0
  62. data/lib/devise/models/trackable.rb +7 -0
  63. data/lib/devise/models/validatable.rb +3 -1
  64. data/lib/devise/models.rb +2 -0
  65. data/lib/devise/modules.rb +2 -0
  66. data/lib/devise/omniauth/config.rb +2 -0
  67. data/lib/devise/omniauth/url_helpers.rb +2 -0
  68. data/lib/devise/omniauth.rb +2 -0
  69. data/lib/devise/orm/active_record.rb +2 -0
  70. data/lib/devise/orm/mongoid.rb +2 -0
  71. data/lib/devise/parameter_filter.rb +2 -0
  72. data/lib/devise/parameter_sanitizer.rb +2 -0
  73. data/lib/devise/rails/routes.rb +2 -0
  74. data/lib/devise/rails/warden_compat.rb +2 -0
  75. data/lib/devise/rails.rb +5 -1
  76. data/lib/devise/strategies/authenticatable.rb +2 -0
  77. data/lib/devise/strategies/base.rb +2 -0
  78. data/lib/devise/strategies/database_authenticatable.rb +2 -0
  79. data/lib/devise/strategies/rememberable.rb +2 -0
  80. data/lib/devise/test/controller_helpers.rb +3 -0
  81. data/lib/devise/test/integration_helpers.rb +2 -0
  82. data/lib/devise/test_helpers.rb +2 -0
  83. data/lib/devise/time_inflector.rb +2 -0
  84. data/lib/devise/token_generator.rb +2 -0
  85. data/lib/devise/version.rb +3 -1
  86. data/lib/devise.rb +3 -1
  87. data/lib/generators/active_record/devise_generator.rb +15 -2
  88. data/lib/generators/active_record/templates/migration.rb +3 -1
  89. data/lib/generators/active_record/templates/migration_existing.rb +2 -0
  90. data/lib/generators/devise/controllers_generator.rb +2 -0
  91. data/lib/generators/devise/devise_generator.rb +4 -2
  92. data/lib/generators/devise/install_generator.rb +2 -0
  93. data/lib/generators/devise/orm_helpers.rb +7 -1
  94. data/lib/generators/devise/views_generator.rb +7 -8
  95. data/lib/generators/mongoid/devise_generator.rb +2 -0
  96. data/lib/generators/templates/controllers/confirmations_controller.rb +2 -0
  97. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +2 -0
  98. data/lib/generators/templates/controllers/passwords_controller.rb +2 -0
  99. data/lib/generators/templates/controllers/registrations_controller.rb +2 -0
  100. data/lib/generators/templates/controllers/sessions_controller.rb +2 -0
  101. data/lib/generators/templates/controllers/unlocks_controller.rb +2 -0
  102. data/lib/generators/templates/devise.rb +6 -0
  103. data/test/controllers/custom_registrations_controller_test.rb +2 -0
  104. data/test/controllers/custom_strategy_test.rb +2 -0
  105. data/test/controllers/helper_methods_test.rb +2 -0
  106. data/test/controllers/helpers_test.rb +2 -0
  107. data/test/controllers/inherited_controller_i18n_messages_test.rb +2 -0
  108. data/test/controllers/internal_helpers_test.rb +2 -0
  109. data/test/controllers/load_hooks_controller_test.rb +2 -0
  110. data/test/controllers/passwords_controller_test.rb +2 -0
  111. data/test/controllers/sessions_controller_test.rb +2 -0
  112. data/test/controllers/url_helpers_test.rb +2 -0
  113. data/test/delegator_test.rb +2 -0
  114. data/test/devise_test.rb +2 -0
  115. data/test/failure_app_test.rb +2 -0
  116. data/test/generators/active_record_generator_test.rb +47 -0
  117. data/test/generators/controllers_generator_test.rb +2 -0
  118. data/test/generators/devise_generator_test.rb +2 -0
  119. data/test/generators/install_generator_test.rb +2 -0
  120. data/test/generators/mongoid_generator_test.rb +2 -0
  121. data/test/generators/views_generator_test.rb +2 -0
  122. data/test/helpers/devise_helper_test.rb +2 -0
  123. data/test/integration/authenticatable_test.rb +9 -1
  124. data/test/integration/confirmable_test.rb +2 -0
  125. data/test/integration/database_authenticatable_test.rb +2 -0
  126. data/test/integration/http_authenticatable_test.rb +8 -0
  127. data/test/integration/lockable_test.rb +5 -3
  128. data/test/integration/mounted_engine_test.rb +2 -0
  129. data/test/integration/omniauthable_test.rb +13 -0
  130. data/test/integration/recoverable_test.rb +2 -0
  131. data/test/integration/registerable_test.rb +2 -0
  132. data/test/integration/rememberable_test.rb +3 -1
  133. data/test/integration/timeoutable_test.rb +2 -0
  134. data/test/integration/trackable_test.rb +7 -0
  135. data/test/mailers/confirmation_instructions_test.rb +2 -0
  136. data/test/mailers/email_changed_test.rb +2 -0
  137. data/test/mailers/mailer_test.rb +2 -0
  138. data/test/mailers/reset_password_instructions_test.rb +2 -0
  139. data/test/mailers/unlock_instructions_test.rb +2 -0
  140. data/test/mapping_test.rb +2 -0
  141. data/test/models/authenticatable_test.rb +2 -0
  142. data/test/models/confirmable_test.rb +13 -0
  143. data/test/models/database_authenticatable_test.rb +2 -0
  144. data/test/models/lockable_test.rb +2 -0
  145. data/test/models/omniauthable_test.rb +2 -0
  146. data/test/models/recoverable_test.rb +2 -0
  147. data/test/models/registerable_test.rb +2 -0
  148. data/test/models/rememberable_test.rb +2 -0
  149. data/test/models/serializable_test.rb +6 -0
  150. data/test/models/timeoutable_test.rb +2 -0
  151. data/test/models/trackable_test.rb +21 -0
  152. data/test/models/validatable_test.rb +4 -2
  153. data/test/models_test.rb +2 -0
  154. data/test/omniauth/config_test.rb +2 -0
  155. data/test/omniauth/url_helpers_test.rb +2 -0
  156. data/test/orm/active_record.rb +8 -1
  157. data/test/orm/mongoid.rb +3 -1
  158. data/test/parameter_sanitizer_test.rb +2 -0
  159. data/test/rails_app/app/active_record/admin.rb +2 -0
  160. data/test/rails_app/app/active_record/shim.rb +2 -0
  161. data/test/rails_app/app/active_record/user.rb +13 -0
  162. data/test/rails_app/app/active_record/user_on_engine.rb +2 -0
  163. data/test/rails_app/app/active_record/user_on_main_app.rb +2 -0
  164. data/test/rails_app/app/active_record/user_with_validations.rb +12 -0
  165. data/test/rails_app/app/active_record/user_without_email.rb +2 -0
  166. data/test/rails_app/app/controllers/admins/sessions_controller.rb +2 -0
  167. data/test/rails_app/app/controllers/admins_controller.rb +2 -0
  168. data/test/rails_app/app/controllers/application_controller.rb +2 -0
  169. data/test/rails_app/app/controllers/application_with_fake_engine.rb +2 -0
  170. data/test/rails_app/app/controllers/custom/registrations_controller.rb +2 -0
  171. data/test/rails_app/app/controllers/home_controller.rb +2 -0
  172. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  173. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  174. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -0
  175. data/test/rails_app/app/controllers/users_controller.rb +2 -0
  176. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  177. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +2 -0
  178. data/test/rails_app/app/mailers/users/mailer.rb +2 -0
  179. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +2 -0
  180. data/test/rails_app/app/mongoid/admin.rb +2 -0
  181. data/test/rails_app/app/mongoid/shim.rb +2 -0
  182. data/test/rails_app/app/mongoid/user.rb +11 -0
  183. data/test/rails_app/app/mongoid/user_on_engine.rb +2 -0
  184. data/test/rails_app/app/mongoid/user_on_main_app.rb +2 -0
  185. data/test/rails_app/app/mongoid/user_with_validations.rb +37 -0
  186. data/test/rails_app/app/mongoid/user_without_email.rb +2 -0
  187. data/test/rails_app/config/application.rb +6 -2
  188. data/test/rails_app/config/boot.rb +8 -1
  189. data/test/rails_app/config/environment.rb +2 -0
  190. data/test/rails_app/config/environments/development.rb +2 -0
  191. data/test/rails_app/config/environments/production.rb +2 -0
  192. data/test/rails_app/config/environments/test.rb +2 -0
  193. data/test/rails_app/config/initializers/backtrace_silencers.rb +2 -0
  194. data/test/rails_app/config/initializers/devise.rb +2 -0
  195. data/test/rails_app/config/initializers/inflections.rb +2 -0
  196. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  197. data/test/rails_app/config/initializers/session_store.rb +2 -0
  198. data/test/rails_app/config/routes.rb +2 -0
  199. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +2 -0
  200. data/test/rails_app/db/schema.rb +2 -0
  201. data/test/rails_app/lib/shared_admin.rb +2 -0
  202. data/test/rails_app/lib/shared_user.rb +2 -0
  203. data/test/rails_app/lib/shared_user_without_email.rb +2 -0
  204. data/test/rails_app/lib/shared_user_without_omniauth.rb +2 -0
  205. data/test/rails_test.rb +2 -0
  206. data/test/routes_test.rb +2 -0
  207. data/test/support/action_controller/record_identifier.rb +2 -0
  208. data/test/support/assertions.rb +2 -0
  209. data/test/support/helpers.rb +6 -0
  210. data/test/support/http_method_compatibility.rb +2 -0
  211. data/test/support/integration.rb +3 -0
  212. data/test/support/webrat/integrations/rails.rb +2 -0
  213. data/test/test/controller_helpers_test.rb +8 -1
  214. data/test/test/integration_helpers_test.rb +2 -0
  215. data/test/test_helper.rb +2 -0
  216. data/test/test_models.rb +2 -0
  217. metadata +12 -5
@@ -0,0 +1,201 @@
1
+ GIT
2
+ remote: git://github.com/rails/activemodel-serializers-xml.git
3
+ revision: 356edf4dfc38fb1fbfee90c87856e4fe5b73c5e1
4
+ specs:
5
+ activemodel-serializers-xml (1.0.2)
6
+ activemodel (> 5.x)
7
+ activesupport (> 5.x)
8
+ builder (~> 3.1)
9
+
10
+ PATH
11
+ remote: ..
12
+ specs:
13
+ devise (4.4.1)
14
+ bcrypt (~> 3.0)
15
+ orm_adapter (~> 0.1)
16
+ railties (>= 4.1.0, < 5.2)
17
+ responders
18
+ warden (~> 1.2.3)
19
+
20
+ GEM
21
+ remote: https://rubygems.org/
22
+ specs:
23
+ actioncable (5.2.0.rc1)
24
+ actionpack (= 5.2.0.rc1)
25
+ nio4r (~> 2.0)
26
+ websocket-driver (>= 0.6.1)
27
+ actionmailer (5.2.0.rc1)
28
+ actionpack (= 5.2.0.rc1)
29
+ actionview (= 5.2.0.rc1)
30
+ activejob (= 5.2.0.rc1)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ rails-dom-testing (~> 2.0)
33
+ actionpack (5.2.0.rc1)
34
+ actionview (= 5.2.0.rc1)
35
+ activesupport (= 5.2.0.rc1)
36
+ rack (~> 2.0)
37
+ rack-test (>= 0.6.3)
38
+ rails-dom-testing (~> 2.0)
39
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
40
+ actionview (5.2.0.rc1)
41
+ activesupport (= 5.2.0.rc1)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
46
+ activejob (5.2.0.rc1)
47
+ activesupport (= 5.2.0.rc1)
48
+ globalid (>= 0.3.6)
49
+ activemodel (5.2.0.rc1)
50
+ activesupport (= 5.2.0.rc1)
51
+ activerecord (5.2.0.rc1)
52
+ activemodel (= 5.2.0.rc1)
53
+ activesupport (= 5.2.0.rc1)
54
+ arel (>= 9.0)
55
+ activestorage (5.2.0.rc1)
56
+ actionpack (= 5.2.0.rc1)
57
+ activerecord (= 5.2.0.rc1)
58
+ marcel (~> 0.3.1)
59
+ activesupport (5.2.0.rc1)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (~> 0.7)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ arel (9.0.0)
65
+ bcrypt (3.1.11)
66
+ builder (3.2.3)
67
+ concurrent-ruby (1.0.5)
68
+ crass (1.0.3)
69
+ erubi (1.7.0)
70
+ faraday (0.12.2)
71
+ multipart-post (>= 1.2, < 3)
72
+ globalid (0.4.1)
73
+ activesupport (>= 4.2.0)
74
+ hashie (3.5.7)
75
+ i18n (0.9.3)
76
+ concurrent-ruby (~> 1.0)
77
+ jwt (1.5.6)
78
+ loofah (2.1.1)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.0)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.1)
84
+ mimemagic (~> 0.3.2)
85
+ metaclass (0.0.4)
86
+ method_source (0.9.0)
87
+ mimemagic (0.3.2)
88
+ mini_mime (1.0.0)
89
+ mini_portile2 (2.3.0)
90
+ minitest (5.11.3)
91
+ mocha (1.3.0)
92
+ metaclass (~> 0.0.1)
93
+ multi_json (1.13.1)
94
+ multi_xml (0.6.0)
95
+ multipart-post (2.0.0)
96
+ nio4r (2.2.0)
97
+ nokogiri (1.8.2)
98
+ mini_portile2 (~> 2.3.0)
99
+ oauth2 (1.4.0)
100
+ faraday (>= 0.8, < 0.13)
101
+ jwt (~> 1.0)
102
+ multi_json (~> 1.3)
103
+ multi_xml (~> 0.5)
104
+ rack (>= 1.2, < 3)
105
+ omniauth (1.8.1)
106
+ hashie (>= 3.4.6, < 3.6.0)
107
+ rack (>= 1.6.2, < 3)
108
+ omniauth-facebook (4.0.0)
109
+ omniauth-oauth2 (~> 1.2)
110
+ omniauth-oauth2 (1.5.0)
111
+ oauth2 (~> 1.1)
112
+ omniauth (~> 1.2)
113
+ omniauth-openid (1.0.1)
114
+ omniauth (~> 1.0)
115
+ rack-openid (~> 1.3.1)
116
+ orm_adapter (0.5.0)
117
+ rack (2.0.4)
118
+ rack-openid (1.3.1)
119
+ rack (>= 1.1.0)
120
+ ruby-openid (>= 2.1.8)
121
+ rack-test (0.8.2)
122
+ rack (>= 1.0, < 3)
123
+ rails (5.2.0.rc1)
124
+ actioncable (= 5.2.0.rc1)
125
+ actionmailer (= 5.2.0.rc1)
126
+ actionpack (= 5.2.0.rc1)
127
+ actionview (= 5.2.0.rc1)
128
+ activejob (= 5.2.0.rc1)
129
+ activemodel (= 5.2.0.rc1)
130
+ activerecord (= 5.2.0.rc1)
131
+ activestorage (= 5.2.0.rc1)
132
+ activesupport (= 5.2.0.rc1)
133
+ bundler (>= 1.3.0)
134
+ railties (= 5.2.0.rc1)
135
+ sprockets-rails (>= 2.0.0)
136
+ rails-controller-testing (1.0.2)
137
+ actionpack (~> 5.x, >= 5.0.1)
138
+ actionview (~> 5.x, >= 5.0.1)
139
+ activesupport (~> 5.x)
140
+ rails-dom-testing (2.0.3)
141
+ activesupport (>= 4.2.0)
142
+ nokogiri (>= 1.6)
143
+ rails-html-sanitizer (1.0.3)
144
+ loofah (~> 2.0)
145
+ railties (5.2.0.rc1)
146
+ actionpack (= 5.2.0.rc1)
147
+ activesupport (= 5.2.0.rc1)
148
+ method_source
149
+ rake (>= 0.8.7)
150
+ thor (>= 0.18.1, < 2.0)
151
+ rake (12.3.0)
152
+ rdoc (6.0.1)
153
+ responders (2.4.0)
154
+ actionpack (>= 4.2.0, < 5.3)
155
+ railties (>= 4.2.0, < 5.3)
156
+ ruby-openid (2.7.0)
157
+ sprockets (3.7.1)
158
+ concurrent-ruby (~> 1.0)
159
+ rack (> 1, < 3)
160
+ sprockets-rails (3.2.1)
161
+ actionpack (>= 4.0)
162
+ activesupport (>= 4.0)
163
+ sprockets (>= 3.0.0)
164
+ sqlite3 (1.3.13)
165
+ test_after_commit (1.1.0)
166
+ activerecord (>= 3.2)
167
+ thor (0.20.0)
168
+ thread_safe (0.3.6)
169
+ tzinfo (1.2.5)
170
+ thread_safe (~> 0.1)
171
+ warden (1.2.7)
172
+ rack (>= 1.0)
173
+ webrat (0.7.3)
174
+ nokogiri (>= 1.2.0)
175
+ rack (>= 1.0)
176
+ rack-test (>= 0.5.3)
177
+ websocket-driver (0.7.0)
178
+ websocket-extensions (>= 0.1.0)
179
+ websocket-extensions (0.1.3)
180
+
181
+ PLATFORMS
182
+ ruby
183
+
184
+ DEPENDENCIES
185
+ activemodel-serializers-xml!
186
+ devise!
187
+ mocha (~> 1.1)
188
+ omniauth
189
+ omniauth-facebook
190
+ omniauth-oauth2
191
+ omniauth-openid
192
+ rails (~> 5.2.0.rc1)
193
+ rails-controller-testing
194
+ rdoc
195
+ responders (~> 2.1)
196
+ sqlite3
197
+ test_after_commit
198
+ webrat (= 0.7.3)
199
+
200
+ BUNDLED WITH
201
+ 1.16.0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/inline'
3
5
  rescue LoadError => e
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Controllers
3
5
  # Those helpers are convenience methods added to ApplicationController.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Controllers
3
5
  # A module that may be optionally included in a controller in order
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Controllers
3
5
  module ScopedViews
@@ -1,10 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Controllers
3
5
  # Provide sign in and sign out functionality.
4
6
  # Included by default in all controllers.
5
7
  module SignInOut
6
8
  # Return true if the given scope is signed in session. If no scope given, return
7
- # true if any scope is signed in. Does not run authentication hooks.
9
+ # true if any scope is signed in. This will run authentication hooks, which may
10
+ # cause exceptions to be thrown from this method; if you simply want to check
11
+ # if a scope has already previously been authenticated without running
12
+ # authentication hooks, you can directly call `warden.authenticated?(scope: scope)`
8
13
  def signed_in?(scope=nil)
9
14
  [scope || Devise.mappings.keys].flatten.any? do |_scope|
10
15
  warden.authenticate?(scope: _scope)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "uri"
2
4
 
3
5
  module Devise
@@ -33,12 +35,9 @@ module Devise
33
35
  #
34
36
  def store_location_for(resource_or_scope, location)
35
37
  session_key = stored_location_key_for(resource_or_scope)
36
- uri = parse_uri(location)
37
- if uri
38
- path = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
39
- path = [path, uri.fragment].compact.join('#')
40
- session[session_key] = path
41
- end
38
+
39
+ path = extract_path_from_location(location)
40
+ session[session_key] = path if path
42
41
  end
43
42
 
44
43
  private
@@ -53,6 +52,25 @@ module Devise
53
52
  scope = Devise::Mapping.find_scope!(resource_or_scope)
54
53
  "#{scope}_return_to"
55
54
  end
55
+
56
+ def extract_path_from_location(location)
57
+ uri = parse_uri(location)
58
+
59
+ if uri
60
+ path = remove_domain_from_uri(uri)
61
+ path = add_fragment_back_to_path(uri, path)
62
+
63
+ path
64
+ end
65
+ end
66
+
67
+ def remove_domain_from_uri(uri)
68
+ [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
69
+ end
70
+
71
+ def add_fragment_back_to_path(uri, path)
72
+ [path, uri.fragment].compact.join('#')
73
+ end
56
74
  end
57
75
  end
58
76
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Controllers
3
5
  # Create url helpers to be used with resource/scope configuration. Acts as
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  # Checks the scope in the given environment and returns the associated failure app.
3
5
  class Delegator
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bcrypt'
2
4
 
3
5
  module Devise
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "action_controller/metal"
2
4
 
3
5
  module Devise
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Deny user access whenever their account is not active yet.
2
4
  # We need this as hook to validate the user activity on each request
3
5
  # and in case the user is using other strategies beside Devise ones.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Warden::Manager.after_authentication do |record, warden, options|
2
4
  clean_up_for_winning_strategy = !warden.winning_strategy.respond_to?(:clean_up_csrf?) ||
3
5
  warden.winning_strategy.clean_up_csrf?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Before logout hook to forget the user in the given scope, if it responds
2
4
  # to forget_me! Also clear remember token to ensure the user won't be
3
5
  # remembered again. Notice that we forget the user unless the record is not persisted.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # After each sign in, if resource responds to failed_attempts, sets it to 0
2
4
  # This is only triggered when the user is explicitly set (with set_user)
3
5
  Warden::Manager.after_set_user except: :fetch do |record, warden, options|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Hooks
3
5
  # A small warden proxy so we can remember, forget and
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Warden::Manager.after_set_user except: :fetch do |record, warden, options|
2
4
  scope = options[:scope]
3
5
  if record.respond_to?(:remember_me) && options[:store] != false &&
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Each time a record is set we check whether its session has already timed out
2
4
  # or not, based on last request time. If so, the record is logged out and
3
5
  # redirected to the sign in page. Also, each time the request comes and the
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # After each sign in, update sign in time, sign in count and sign in IP.
2
4
  # This is only triggered when the user is explicitly set (with set_user)
3
5
  # and on authentication. Retrieving the user from session (:fetch) does
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Mailers
3
5
  module Helpers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  # Responsible for handling devise mappings and routes configuration. Each
3
5
  # resource configured by devise_for in routes is actually creating a mapping
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_model/version'
2
4
  require 'devise/hooks/activatable'
3
5
  require 'devise/hooks/csrf_cleaner'
@@ -102,7 +104,7 @@ module Devise
102
104
  # and passing a new list of attributes you want to exempt. All attributes
103
105
  # given to :except will simply add names to exempt to Devise internal list.
104
106
  def serializable_hash(options = nil)
105
- options ||= {}
107
+ options = options.try(:dup) || {}
106
108
  options[:except] = Array(options[:except])
107
109
 
108
110
  if options[:force_except]
@@ -256,7 +258,7 @@ module Devise
256
258
  # end
257
259
  #
258
260
  # Finally, notice that Devise also queries for users in other scenarios
259
- # besides authentication, for example when retrieving an user to send
261
+ # besides authentication, for example when retrieving a user to send
260
262
  # an e-mail for password reset. In such cases, find_for_authentication
261
263
  # is not called.
262
264
  def find_for_authentication(tainted_conditions)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Models
3
5
  # Confirmable is responsible to verify if an account is already confirmed to
@@ -46,7 +48,7 @@ module Devise
46
48
  included do
47
49
  before_create :generate_confirmation_token, if: :confirmation_required?
48
50
  after_create :skip_reconfirmation_in_callback!, if: :send_confirmation_notification?
49
- if respond_to?(:after_commit) # ActiveRecord
51
+ if defined?(ActiveRecord) && self < ActiveRecord::Base # ActiveRecord
50
52
  after_commit :send_on_create_confirmation_instructions, on: :create, if: :send_confirmation_notification?
51
53
  after_commit :send_reconfirmation_instructions, on: :update, if: :reconfirmation_required?
52
54
  else # Mongoid
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/strategies/database_authenticatable'
2
4
 
3
5
  module Devise
@@ -10,7 +12,7 @@ module Devise
10
12
  # DatabaseAuthenticatable adds the following options to devise_for:
11
13
  #
12
14
  # * +pepper+: a random string used to provide a more secure hash. Use
13
- # `rake secret` to generate new keys.
15
+ # `rails secret` to generate new keys.
14
16
  #
15
17
  # * +stretches+: the cost given to bcrypt.
16
18
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "devise/hooks/lockable"
2
4
 
3
5
  module Devise
@@ -99,8 +101,7 @@ module Devise
99
101
  if super && !access_locked?
100
102
  true
101
103
  else
102
- self.failed_attempts ||= 0
103
- self.failed_attempts += 1
104
+ increment_failed_attempts
104
105
  if attempts_exceeded?
105
106
  lock_access! unless access_locked?
106
107
  else
@@ -109,6 +110,11 @@ module Devise
109
110
  false
110
111
  end
111
112
  end
113
+
114
+ def increment_failed_attempts
115
+ self.failed_attempts ||= 0
116
+ self.failed_attempts += 1
117
+ end
112
118
 
113
119
  def unauthenticated_message
114
120
  # If set to paranoid mode, do not show the locked message because it
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/omniauth'
2
4
 
3
5
  module Devise
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Models
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Models
3
5
  # Registerable is responsible for everything related to registering a new
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/strategies/rememberable'
2
4
  require 'devise/hooks/rememberable'
3
5
  require 'devise/hooks/forgetable'
4
6
 
5
7
  module Devise
6
8
  module Models
7
- # Rememberable manages generating and clearing token for remember the user
9
+ # Rememberable manages generating and clearing token for remembering the user
8
10
  # from a saved cookie. Rememberable also has utility methods for dealing
9
11
  # with serializing the user into the cookie and back from the cookie, trying
10
12
  # to lookup the record based on the saved information.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/hooks/timeoutable'
2
4
 
3
5
  module Devise
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/hooks/trackable'
2
4
 
3
5
  module Devise
@@ -29,6 +31,11 @@ module Devise
29
31
  end
30
32
 
31
33
  def update_tracked_fields!(request)
34
+ # We have to check if the user is already persisted before running
35
+ # `save` here because invalid users can be saved if we don't.
36
+ # See https://github.com/plataformatec/devise/issues/4673 for more details.
37
+ return if new_record?
38
+
32
39
  update_tracked_fields(request)
33
40
  save(validate: false)
34
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Models
3
5
  # Validatable creates all needed validations for a user email and password.
@@ -10,7 +12,7 @@ module Devise
10
12
  # Validatable adds the following options to devise_for:
11
13
  #
12
14
  # * +email_regexp+: the regular expression used to validate e-mails;
13
- # * +password_length+: a range expressing password length. Defaults to 8..72.
15
+ # * +password_length+: a range expressing password length. Defaults to 6..128.
14
16
  #
15
17
  module Validatable
16
18
  # All validations used by this module.
data/lib/devise/models.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Models
3
5
  class MissingAttribute < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/core_ext/object/with_options'
2
4
 
3
5
  Devise.with_options model: true do |d|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module OmniAuth
3
5
  class StrategyNotFound < NameError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module OmniAuth
3
5
  module UrlHelpers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require "omniauth"
3
5
  require "omniauth/version"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'orm_adapter/adapters/active_record'
2
4
 
3
5
  ActiveSupport.on_load(:active_record) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ActiveSupport.on_load(:mongoid) do
2
4
  require 'orm_adapter/adapters/mongoid'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  class ParameterFilter
3
5
  def initialize(case_insensitive_keys, strip_whitespace_keys)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  # The +ParameterSanitizer+ deals with permitting specific parameters values
3
5
  # for each +Devise+ scope in the application.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "active_support/core_ext/object/try"
2
4
  require "active_support/core_ext/hash/slice"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Warden::Mixins::Common
2
4
  def request
3
5
  @request ||= ActionDispatch::Request.new(env)
data/lib/devise/rails.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/rails/routes'
2
4
  require 'devise/rails/warden_compat'
3
5
 
@@ -32,7 +34,9 @@ module Devise
32
34
  end
33
35
 
34
36
  initializer "devise.secret_key" do |app|
35
- if app.respond_to?(:secrets)
37
+ if app.respond_to?(:credentials)
38
+ Devise.secret_key ||= app.credentials.secret_key_base
39
+ elsif app.respond_to?(:secrets)
36
40
  Devise.secret_key ||= app.secrets.secret_key_base
37
41
  elsif app.config.respond_to?(:secret_key_base)
38
42
  Devise.secret_key ||= app.config.secret_key_base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'devise/strategies/base'
2
4
 
3
5
  module Devise
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Devise
2
4
  module Strategies
3
5
  # Base strategy for Devise. Responsible for verifying correct scope and mapping.