devise 3.2.4 → 3.3.0

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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +12 -5
  4. data/CHANGELOG.md +28 -1
  5. data/Gemfile +5 -5
  6. data/Gemfile.lock +98 -92
  7. data/README.md +22 -16
  8. data/app/controllers/devise/confirmations_controller.rb +1 -1
  9. data/app/controllers/devise/registrations_controller.rb +18 -5
  10. data/app/controllers/devise/sessions_controller.rb +32 -9
  11. data/app/controllers/devise_controller.rb +3 -3
  12. data/app/views/devise/registrations/new.html.erb +1 -1
  13. data/app/views/devise/sessions/new.html.erb +2 -2
  14. data/app/views/devise/shared/_links.erb +1 -1
  15. data/config/locales/en.yml +16 -15
  16. data/gemfiles/Gemfile.rails-3.2-stable +3 -3
  17. data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
  18. data/gemfiles/Gemfile.rails-4.0-stable +4 -4
  19. data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
  20. data/gemfiles/Gemfile.rails-head +7 -4
  21. data/gemfiles/Gemfile.rails-head.lock +190 -0
  22. data/lib/devise.rb +8 -4
  23. data/lib/devise/controllers/helpers.rb +77 -6
  24. data/lib/devise/controllers/sign_in_out.rb +0 -1
  25. data/lib/devise/controllers/store_location.rb +8 -2
  26. data/lib/devise/controllers/url_helpers.rb +3 -1
  27. data/lib/devise/failure_app.rb +6 -6
  28. data/lib/devise/hooks/activatable.rb +3 -4
  29. data/lib/devise/hooks/csrf_cleaner.rb +3 -1
  30. data/lib/devise/hooks/timeoutable.rb +8 -1
  31. data/lib/devise/mapping.rb +4 -1
  32. data/lib/devise/models/confirmable.rb +3 -3
  33. data/lib/devise/models/database_authenticatable.rb +7 -3
  34. data/lib/devise/models/lockable.rb +2 -2
  35. data/lib/devise/models/recoverable.rb +23 -7
  36. data/lib/devise/models/rememberable.rb +2 -2
  37. data/lib/devise/models/trackable.rb +4 -1
  38. data/lib/devise/rails/routes.rb +8 -6
  39. data/lib/devise/strategies/authenticatable.rb +7 -0
  40. data/lib/devise/version.rb +1 -1
  41. data/lib/generators/active_record/devise_generator.rb +19 -2
  42. data/lib/generators/templates/README +1 -1
  43. data/lib/generators/templates/devise.rb +3 -0
  44. data/script/cached-bundle +49 -0
  45. data/script/s3-put +71 -0
  46. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  47. data/test/controllers/helpers_test.rb +35 -0
  48. data/test/controllers/internal_helpers_test.rb +1 -1
  49. data/test/controllers/passwords_controller_test.rb +1 -1
  50. data/test/devise_test.rb +18 -5
  51. data/test/failure_app_test.rb +40 -4
  52. data/test/generators/active_record_generator_test.rb +6 -0
  53. data/test/helpers/devise_helper_test.rb +3 -2
  54. data/test/integration/authenticatable_test.rb +19 -3
  55. data/test/integration/confirmable_test.rb +49 -9
  56. data/test/integration/http_authenticatable_test.rb +1 -1
  57. data/test/integration/lockable_test.rb +6 -6
  58. data/test/integration/recoverable_test.rb +5 -5
  59. data/test/integration/registerable_test.rb +32 -22
  60. data/test/integration/timeoutable_test.rb +8 -2
  61. data/test/integration/trackable_test.rb +2 -2
  62. data/test/mailers/confirmation_instructions_test.rb +3 -3
  63. data/test/mailers/reset_password_instructions_test.rb +3 -3
  64. data/test/mailers/unlock_instructions_test.rb +3 -3
  65. data/test/models/authenticatable_test.rb +1 -1
  66. data/test/models/lockable_test.rb +6 -0
  67. data/test/models/recoverable_test.rb +12 -0
  68. data/test/models/rememberable_test.rb +21 -6
  69. data/test/models/trackable_test.rb +28 -0
  70. data/test/models/validatable_test.rb +2 -2
  71. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  72. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  73. data/test/rails_app/app/controllers/application_controller.rb +3 -0
  74. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  75. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  76. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
  77. data/test/rails_app/app/controllers/users_controller.rb +1 -1
  78. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  79. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  80. data/test/rails_app/config/application.rb +1 -1
  81. data/test/rails_app/config/initializers/devise.rb +2 -0
  82. data/test/rails_app/config/routes.rb +17 -0
  83. data/test/rails_app/lib/shared_user.rb +1 -1
  84. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  85. data/test/routes_test.rb +5 -3
  86. data/test/support/assertions.rb +2 -3
  87. data/test/support/integration.rb +2 -2
  88. data/test/test_helper.rb +2 -0
  89. data/test/test_helpers_test.rb +22 -32
  90. metadata +23 -2
@@ -0,0 +1,162 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: 6d95e04c6968fb7597ea5dbd08b31f271fb87c9c
4
+ branch: 4-0-stable
5
+ specs:
6
+ actionmailer (4.0.8)
7
+ actionpack (= 4.0.8)
8
+ mail (~> 2.5, >= 2.5.4)
9
+ actionpack (4.0.8)
10
+ activesupport (= 4.0.8)
11
+ builder (~> 3.1.0)
12
+ erubis (~> 2.7.0)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ activemodel (4.0.8)
16
+ activesupport (= 4.0.8)
17
+ builder (~> 3.1.0)
18
+ activerecord (4.0.8)
19
+ activemodel (= 4.0.8)
20
+ activerecord-deprecated_finders (~> 1.0.2)
21
+ activesupport (= 4.0.8)
22
+ arel (~> 4.0.0)
23
+ activesupport (4.0.8)
24
+ i18n (~> 0.6, >= 0.6.9)
25
+ minitest (~> 4.2)
26
+ multi_json (~> 1.3)
27
+ thread_safe (~> 0.1)
28
+ tzinfo (~> 0.3.37)
29
+ rails (4.0.8)
30
+ actionmailer (= 4.0.8)
31
+ actionpack (= 4.0.8)
32
+ activerecord (= 4.0.8)
33
+ activesupport (= 4.0.8)
34
+ bundler (>= 1.3.0, < 2.0)
35
+ railties (= 4.0.8)
36
+ sprockets-rails (~> 2.0)
37
+ railties (4.0.8)
38
+ actionpack (= 4.0.8)
39
+ activesupport (= 4.0.8)
40
+ rake (>= 0.8.7)
41
+ thor (>= 0.18.1, < 2.0)
42
+
43
+ PATH
44
+ remote: ..
45
+ specs:
46
+ devise (3.3.0)
47
+ bcrypt (~> 3.0)
48
+ orm_adapter (~> 0.1)
49
+ railties (>= 3.2.6, < 5)
50
+ thread_safe (~> 0.1)
51
+ warden (~> 1.2.3)
52
+
53
+ GEM
54
+ remote: https://rubygems.org/
55
+ specs:
56
+ activerecord-deprecated_finders (1.0.3)
57
+ arel (4.0.2)
58
+ bcrypt (3.1.7)
59
+ bson (2.3.0)
60
+ builder (3.1.4)
61
+ connection_pool (2.0.0)
62
+ erubis (2.7.0)
63
+ faraday (0.9.0)
64
+ multipart-post (>= 1.2, < 3)
65
+ hashie (3.2.0)
66
+ hike (1.2.3)
67
+ i18n (0.6.11)
68
+ json (1.8.1)
69
+ jwt (1.0.0)
70
+ mail (2.6.1)
71
+ mime-types (>= 1.16, < 3)
72
+ metaclass (0.0.4)
73
+ mime-types (2.3)
74
+ mini_portile (0.6.0)
75
+ minitest (4.7.5)
76
+ mocha (1.1.0)
77
+ metaclass (~> 0.0.1)
78
+ mongoid (4.0.0)
79
+ activemodel (~> 4.0)
80
+ moped (~> 2.0.0)
81
+ origin (~> 2.1)
82
+ tzinfo (>= 0.3.37)
83
+ moped (2.0.0)
84
+ bson (~> 2.2)
85
+ connection_pool (~> 2.0)
86
+ optionable (~> 0.2.0)
87
+ multi_json (1.10.1)
88
+ multi_xml (0.5.5)
89
+ multipart-post (2.0.0)
90
+ nokogiri (1.6.3.1)
91
+ mini_portile (= 0.6.0)
92
+ oauth2 (0.9.4)
93
+ faraday (>= 0.8, < 0.10)
94
+ jwt (~> 1.0)
95
+ multi_json (~> 1.3)
96
+ multi_xml (~> 0.5)
97
+ rack (~> 1.2)
98
+ omniauth (1.2.2)
99
+ hashie (>= 1.2, < 4)
100
+ rack (~> 1.0)
101
+ omniauth-facebook (1.6.0)
102
+ omniauth-oauth2 (~> 1.1)
103
+ omniauth-oauth2 (1.1.2)
104
+ faraday (>= 0.8, < 0.10)
105
+ multi_json (~> 1.3)
106
+ oauth2 (~> 0.9.3)
107
+ omniauth (~> 1.2)
108
+ omniauth-openid (1.0.1)
109
+ omniauth (~> 1.0)
110
+ rack-openid (~> 1.3.1)
111
+ optionable (0.2.0)
112
+ origin (2.1.1)
113
+ orm_adapter (0.5.0)
114
+ rack (1.5.2)
115
+ rack-openid (1.3.1)
116
+ rack (>= 1.1.0)
117
+ ruby-openid (>= 2.1.8)
118
+ rack-test (0.6.2)
119
+ rack (>= 1.0)
120
+ rake (10.3.2)
121
+ rdoc (4.1.1)
122
+ json (~> 1.4)
123
+ ruby-openid (2.5.0)
124
+ sprockets (2.12.1)
125
+ hike (~> 1.2)
126
+ multi_json (~> 1.0)
127
+ rack (~> 1.0)
128
+ tilt (~> 1.1, != 1.3.0)
129
+ sprockets-rails (2.1.3)
130
+ actionpack (>= 3.0)
131
+ activesupport (>= 3.0)
132
+ sprockets (~> 2.8)
133
+ sqlite3 (1.3.9)
134
+ thor (0.19.1)
135
+ thread_safe (0.3.4)
136
+ tilt (1.4.1)
137
+ tzinfo (0.3.40)
138
+ warden (1.2.3)
139
+ rack (>= 1.0)
140
+ webrat (0.7.3)
141
+ nokogiri (>= 1.2.0)
142
+ rack (>= 1.0)
143
+ rack-test (>= 0.5.3)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ activerecord-jdbc-adapter
150
+ activerecord-jdbcsqlite3-adapter
151
+ devise!
152
+ jruby-openssl
153
+ mocha (~> 1.1)
154
+ mongoid (~> 4.0.0)
155
+ omniauth (~> 1.2.0)
156
+ omniauth-facebook
157
+ omniauth-oauth2 (~> 1.1.0)
158
+ omniauth-openid (~> 1.0.1)
159
+ rails!
160
+ rdoc
161
+ sqlite3
162
+ webrat (= 0.7.3)
@@ -2,16 +2,19 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: '..'
4
4
 
5
- gem "rails", github: 'rails/rails'
6
- gem "omniauth", "~> 1.0.0"
7
- gem "omniauth-oauth2", "~> 1.0.0"
5
+ gem "rails", github: "rails/rails"
6
+ gem "arel", github: "rails/arel"
7
+ gem "rack", github: "rack/rack"
8
+ gem "i18n", github: "svenfuchs/i18n"
9
+ gem "omniauth", "~> 1.2.0"
10
+ gem "omniauth-oauth2", "~> 1.1.0"
8
11
  gem "rdoc"
9
12
 
10
13
  group :test do
11
14
  gem "omniauth-facebook"
12
15
  gem "omniauth-openid", "~> 1.0.1"
13
16
  gem "webrat", "0.7.3", require: false
14
- gem "mocha", "~> 1.0.0", require: false
17
+ gem "mocha", "~> 1.1", require: false
15
18
  end
16
19
 
17
20
  platforms :jruby do
@@ -0,0 +1,190 @@
1
+ GIT
2
+ remote: git://github.com/mongoid/mongoid.git
3
+ revision: 8cb17e9839973b76295cf87189e91a5ffcc03ab0
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
+ GIT
13
+ remote: git://github.com/rack/rack.git
14
+ revision: 92811eec6e86cb4dba52b3969c4dd66e639df158
15
+ specs:
16
+ rack (1.6.0.alpha)
17
+
18
+ GIT
19
+ remote: git://github.com/rails/arel.git
20
+ revision: 66cee768bc163537087037a583f60639eae49fc3
21
+ specs:
22
+ arel (6.0.0.20140505020427)
23
+
24
+ GIT
25
+ remote: git://github.com/rails/rails.git
26
+ revision: d5be08347fb7ff758572775ec93247a3ca886004
27
+ specs:
28
+ actionmailer (4.2.0.alpha)
29
+ actionpack (= 4.2.0.alpha)
30
+ actionview (= 4.2.0.alpha)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ actionpack (4.2.0.alpha)
33
+ actionview (= 4.2.0.alpha)
34
+ activesupport (= 4.2.0.alpha)
35
+ rack (~> 1.6.0.alpha)
36
+ rack-test (~> 0.6.2)
37
+ actionview (4.2.0.alpha)
38
+ activesupport (= 4.2.0.alpha)
39
+ builder (~> 3.1)
40
+ erubis (~> 2.7.0)
41
+ activemodel (4.2.0.alpha)
42
+ activesupport (= 4.2.0.alpha)
43
+ builder (~> 3.1)
44
+ activerecord (4.2.0.alpha)
45
+ activemodel (= 4.2.0.alpha)
46
+ activesupport (= 4.2.0.alpha)
47
+ arel (~> 6.0.0)
48
+ activesupport (4.2.0.alpha)
49
+ i18n (>= 0.7.0.dev, < 0.8)
50
+ json (~> 1.7, >= 1.7.7)
51
+ minitest (~> 5.1)
52
+ thread_safe (~> 0.1)
53
+ tzinfo (~> 1.1)
54
+ rails (4.2.0.alpha)
55
+ actionmailer (= 4.2.0.alpha)
56
+ actionpack (= 4.2.0.alpha)
57
+ actionview (= 4.2.0.alpha)
58
+ activemodel (= 4.2.0.alpha)
59
+ activerecord (= 4.2.0.alpha)
60
+ activesupport (= 4.2.0.alpha)
61
+ bundler (>= 1.3.0, < 2.0)
62
+ railties (= 4.2.0.alpha)
63
+ sprockets-rails (~> 2.1)
64
+ railties (4.2.0.alpha)
65
+ actionpack (= 4.2.0.alpha)
66
+ activesupport (= 4.2.0.alpha)
67
+ rake (>= 0.8.7)
68
+ thor (>= 0.18.1, < 2.0)
69
+
70
+ GIT
71
+ remote: git://github.com/svenfuchs/i18n.git
72
+ revision: cb679b8cdbab675703a3f88de4d48a48f7b50e06
73
+ specs:
74
+ i18n (0.7.0.dev)
75
+
76
+ PATH
77
+ remote: ..
78
+ specs:
79
+ devise (3.3.0)
80
+ bcrypt (~> 3.0)
81
+ orm_adapter (~> 0.1)
82
+ railties (>= 3.2.6, < 5)
83
+ thread_safe (~> 0.1)
84
+ warden (~> 1.2.3)
85
+
86
+ GEM
87
+ remote: https://rubygems.org/
88
+ specs:
89
+ bcrypt (3.1.7)
90
+ bson (2.3.0)
91
+ builder (3.2.2)
92
+ connection_pool (2.0.0)
93
+ erubis (2.7.0)
94
+ faraday (0.9.0)
95
+ multipart-post (>= 1.2, < 3)
96
+ hashie (3.2.0)
97
+ hike (1.2.3)
98
+ json (1.8.1)
99
+ jwt (1.0.0)
100
+ mail (2.6.1)
101
+ mime-types (>= 1.16, < 3)
102
+ metaclass (0.0.4)
103
+ mime-types (2.3)
104
+ mini_portile (0.6.0)
105
+ minitest (5.4.0)
106
+ mocha (1.1.0)
107
+ metaclass (~> 0.0.1)
108
+ moped (2.0.0)
109
+ bson (~> 2.2)
110
+ connection_pool (~> 2.0)
111
+ optionable (~> 0.2.0)
112
+ multi_json (1.10.1)
113
+ multi_xml (0.5.5)
114
+ multipart-post (2.0.0)
115
+ nokogiri (1.6.3.1)
116
+ mini_portile (= 0.6.0)
117
+ oauth2 (0.9.4)
118
+ faraday (>= 0.8, < 0.10)
119
+ jwt (~> 1.0)
120
+ multi_json (~> 1.3)
121
+ multi_xml (~> 0.5)
122
+ rack (~> 1.2)
123
+ omniauth (1.2.2)
124
+ hashie (>= 1.2, < 4)
125
+ rack (~> 1.0)
126
+ omniauth-facebook (1.6.0)
127
+ omniauth-oauth2 (~> 1.1)
128
+ omniauth-oauth2 (1.1.2)
129
+ faraday (>= 0.8, < 0.10)
130
+ multi_json (~> 1.3)
131
+ oauth2 (~> 0.9.3)
132
+ omniauth (~> 1.2)
133
+ omniauth-openid (1.0.1)
134
+ omniauth (~> 1.0)
135
+ rack-openid (~> 1.3.1)
136
+ optionable (0.2.0)
137
+ origin (2.1.1)
138
+ orm_adapter (0.5.0)
139
+ rack-openid (1.3.1)
140
+ rack (>= 1.1.0)
141
+ ruby-openid (>= 2.1.8)
142
+ rack-test (0.6.2)
143
+ rack (>= 1.0)
144
+ rake (10.3.2)
145
+ rdoc (4.1.1)
146
+ json (~> 1.4)
147
+ ruby-openid (2.5.0)
148
+ sprockets (2.12.1)
149
+ hike (~> 1.2)
150
+ multi_json (~> 1.0)
151
+ rack (~> 1.0)
152
+ tilt (~> 1.1, != 1.3.0)
153
+ sprockets-rails (2.1.3)
154
+ actionpack (>= 3.0)
155
+ activesupport (>= 3.0)
156
+ sprockets (~> 2.8)
157
+ sqlite3 (1.3.9)
158
+ thor (0.19.1)
159
+ thread_safe (0.3.4)
160
+ tilt (1.4.1)
161
+ tzinfo (1.2.1)
162
+ thread_safe (~> 0.1)
163
+ warden (1.2.3)
164
+ rack (>= 1.0)
165
+ webrat (0.7.3)
166
+ nokogiri (>= 1.2.0)
167
+ rack (>= 1.0)
168
+ rack-test (>= 0.5.3)
169
+
170
+ PLATFORMS
171
+ ruby
172
+
173
+ DEPENDENCIES
174
+ activerecord-jdbc-adapter
175
+ activerecord-jdbcsqlite3-adapter
176
+ arel!
177
+ devise!
178
+ i18n!
179
+ jruby-openssl
180
+ mocha (~> 1.1)
181
+ mongoid!
182
+ omniauth (~> 1.2.0)
183
+ omniauth-facebook
184
+ omniauth-oauth2 (~> 1.1.0)
185
+ omniauth-openid (~> 1.0.1)
186
+ rack!
187
+ rails!
188
+ rdoc
189
+ sqlite3
190
+ webrat (= 0.7.3)
@@ -134,6 +134,10 @@ module Devise
134
134
  mattr_accessor :extend_remember_period
135
135
  @@extend_remember_period = false
136
136
 
137
+ # If true, all the remember me tokens are going to be invalidated when the user signs out.
138
+ mattr_accessor :expire_all_remember_me_on_sign_out
139
+ @@expire_all_remember_me_on_sign_out = true
140
+
137
141
  # Time interval you can access your account before confirming your account.
138
142
  # nil - allows unconfirmed access for unlimited time
139
143
  mattr_accessor :allow_unconfirmed_access_for
@@ -268,7 +272,7 @@ module Devise
268
272
  # Private methods to interface with Warden.
269
273
  mattr_accessor :warden_config
270
274
  @@warden_config = nil
271
- @@warden_config_block = nil
275
+ @@warden_config_blocks = []
272
276
 
273
277
  # When true, enter in paranoid mode to avoid user enumeration.
274
278
  mattr_accessor :paranoid
@@ -400,7 +404,7 @@ module Devise
400
404
  # Sets warden configuration using a block that will be invoked on warden
401
405
  # initialization.
402
406
  #
403
- # Devise.initialize do |config|
407
+ # Devise.setup do |config|
404
408
  # config.allow_unconfirmed_access_for = 2.days
405
409
  #
406
410
  # config.warden do |manager|
@@ -409,7 +413,7 @@ module Devise
409
413
  # end
410
414
  # end
411
415
  def self.warden(&block)
412
- @@warden_config_block = block
416
+ @@warden_config_blocks << block
413
417
  end
414
418
 
415
419
  # Specify an omniauth provider.
@@ -463,7 +467,7 @@ module Devise
463
467
  end
464
468
  end
465
469
 
466
- @@warden_config_block.try :call, Devise.warden_config
470
+ @@warden_config_blocks.map { |block| block.call Devise.warden_config }
467
471
  true
468
472
  end
469
473
  end
@@ -11,6 +11,68 @@ module Devise
11
11
  end
12
12
 
13
13
  module ClassMethods
14
+ # Define authentication filters and accessor helpers for a group of mappings.
15
+ # These methods are useful when you are working with multiple mappings that
16
+ # share some functionality. They are pretty much the same as the ones
17
+ # defined for normal mappings.
18
+ #
19
+ # Example:
20
+ #
21
+ # inside BlogsController (or any other controller, it doesn't matter which):
22
+ # devise_group :blogger, contains: [:user, :admin]
23
+ #
24
+ # Generated methods:
25
+ # authenticate_blogger! # Redirects unless user or admin are signed in
26
+ # blogger_signed_in? # Checks whether there is either a user or an admin signed in
27
+ # current_blogger # Currently signed in user or admin
28
+ # current_bloggers # Currently signed in user and admin
29
+ #
30
+ # Use:
31
+ # before_filter :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
32
+ # before_filter ->{ authenticate_blogger! :admin } # Redirects to the admin login page
33
+ # current_blogger :user # Preferably returns a User if one is signed in
34
+ #
35
+ def devise_group(group_name, opts={})
36
+ mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]"
37
+
38
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
39
+ def authenticate_#{group_name}!(favourite=nil, opts={})
40
+ unless #{group_name}_signed_in?
41
+ mappings = #{mappings}
42
+ mappings.unshift mappings.delete(favourite.to_sym) if favourite
43
+ mappings.each do |mapping|
44
+ opts[:scope] = mapping
45
+ warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
46
+ end
47
+ end
48
+ end
49
+
50
+ def #{group_name}_signed_in?
51
+ #{mappings}.any? do |mapping|
52
+ warden.authenticate?(scope: mapping)
53
+ end
54
+ end
55
+
56
+ def current_#{group_name}(favourite=nil)
57
+ mappings = #{mappings}
58
+ mappings.unshift mappings.delete(favourite.to_sym) if favourite
59
+ mappings.each do |mapping|
60
+ current = warden.authenticate(scope: mapping)
61
+ return current if current
62
+ end
63
+ nil
64
+ end
65
+
66
+ def current_#{group_name.to_s.pluralize}
67
+ #{mappings}.map do |mapping|
68
+ warden.authenticate(scope: mapping)
69
+ end.compact
70
+ end
71
+
72
+ helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
73
+ METHODS
74
+ end
75
+
14
76
  def log_process_action(payload)
15
77
  payload[:status] ||= 401 unless payload[:exception]
16
78
  super
@@ -102,9 +164,16 @@ module Devise
102
164
  # tries to find a resource_root_path, otherwise it uses the root_path.
103
165
  def signed_in_root_path(resource_or_scope)
104
166
  scope = Devise::Mapping.find_scope!(resource_or_scope)
167
+ router_name = Devise.mappings[scope].router_name
168
+
105
169
  home_path = "#{scope}_root_path"
106
- if respond_to?(home_path, true)
107
- send(home_path)
170
+
171
+ context = router_name ? send(router_name) : self
172
+
173
+ if context.respond_to?(home_path, true)
174
+ context.send(home_path)
175
+ elsif context.respond_to?(:root_path)
176
+ context.root_path
108
177
  elsif respond_to?(:root_path)
109
178
  root_path
110
179
  else
@@ -150,7 +219,10 @@ module Devise
150
219
  #
151
220
  # By default it is the root_path.
152
221
  def after_sign_out_path_for(resource_or_scope)
153
- respond_to?(:root_path) ? root_path : "/"
222
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
223
+ router_name = Devise.mappings[scope].router_name
224
+ context = router_name ? send(router_name) : self
225
+ context.respond_to?(:root_path) ? context.root_path : "/"
154
226
  end
155
227
 
156
228
  # Sign in a user and tries to redirect first to the stored location and
@@ -176,10 +248,9 @@ module Devise
176
248
  # Overwrite Rails' handle unverified request to sign out all scopes,
177
249
  # clear run strategies and remove cached variables.
178
250
  def handle_unverified_request
179
- sign_out_all_scopes(false)
251
+ super # call the default behaviour which resets/nullifies/raises
180
252
  request.env["devise.skip_storage"] = true
181
- expire_data_after_sign_out!
182
- super # call the default behaviour which resets the session
253
+ sign_out_all_scopes(false)
183
254
  end
184
255
 
185
256
  def request_format