devise 4.1.1 → 4.2.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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -7
- data/CHANGELOG.md +46 -2
- data/CONTRIBUTING.md +30 -7
- data/Gemfile +14 -7
- data/Gemfile.lock +96 -81
- data/README.md +89 -37
- data/app/controllers/devise/omniauth_callbacks_controller.rb +3 -3
- data/app/controllers/devise/registrations_controller.rb +3 -3
- data/app/views/devise/registrations/edit.html.erb +4 -0
- data/gemfiles/Gemfile.rails-4.1-stable +4 -4
- data/gemfiles/Gemfile.rails-4.1-stable.lock +27 -23
- data/gemfiles/Gemfile.rails-4.2-stable +4 -4
- data/gemfiles/Gemfile.rails-4.2-stable.lock +58 -54
- data/guides/bug_report_templates/integration_test.rb +104 -0
- data/lib/devise.rb +21 -14
- data/lib/devise/controllers/helpers.rb +12 -1
- data/lib/devise/controllers/rememberable.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +25 -10
- data/lib/devise/failure_app.rb +25 -17
- data/lib/devise/hooks/proxy.rb +1 -1
- data/lib/devise/models/authenticatable.rb +23 -2
- data/lib/devise/models/confirmable.rb +13 -7
- data/lib/devise/models/database_authenticatable.rb +0 -5
- data/lib/devise/models/recoverable.rb +10 -15
- data/lib/devise/omniauth/url_helpers.rb +0 -51
- data/lib/devise/orm/active_record.rb +3 -1
- data/lib/devise/orm/mongoid.rb +4 -2
- data/lib/devise/parameter_sanitizer.rb +0 -55
- data/lib/devise/rails.rb +3 -1
- data/lib/devise/test/controller_helpers.rb +162 -0
- data/lib/devise/test/integration_helpers.rb +61 -0
- data/lib/devise/test_helpers.rb +5 -129
- data/lib/devise/version.rb +1 -1
- data/lib/generators/templates/README +1 -8
- data/lib/generators/templates/devise.rb +6 -0
- data/test/controllers/custom_registrations_controller_test.rb +1 -1
- data/test/controllers/custom_strategy_test.rb +1 -1
- data/test/controllers/helpers_test.rb +4 -4
- data/test/controllers/internal_helpers_test.rb +1 -1
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/controllers/sessions_controller_test.rb +2 -2
- data/test/devise_test.rb +9 -9
- data/test/failure_app_test.rb +18 -0
- data/test/integration/authenticatable_test.rb +36 -36
- data/test/integration/confirmable_test.rb +7 -7
- data/test/integration/database_authenticatable_test.rb +5 -5
- data/test/integration/http_authenticatable_test.rb +2 -2
- data/test/integration/lockable_test.rb +1 -1
- data/test/integration/mounted_engine_test.rb +36 -0
- data/test/integration/omniauthable_test.rb +1 -1
- data/test/integration/recoverable_test.rb +4 -4
- data/test/integration/registerable_test.rb +12 -6
- data/test/integration/rememberable_test.rb +10 -10
- data/test/integration/timeoutable_test.rb +5 -5
- data/test/mapping_test.rb +1 -1
- data/test/models/confirmable_test.rb +33 -25
- data/test/models/database_authenticatable_test.rb +13 -13
- data/test/models/lockable_test.rb +16 -16
- data/test/models/omniauthable_test.rb +1 -1
- data/test/models/recoverable_test.rb +10 -10
- data/test/models/registerable_test.rb +1 -1
- data/test/models/rememberable_test.rb +16 -3
- data/test/models/serializable_test.rb +5 -0
- data/test/models/timeoutable_test.rb +7 -7
- data/test/models/trackable_test.rb +1 -1
- data/test/models/validatable_test.rb +1 -1
- data/test/models_test.rb +2 -2
- data/test/parameter_sanitizer_test.rb +0 -56
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
- data/test/rails_app/config/environments/production.rb +3 -1
- data/test/rails_app/config/environments/test.rb +5 -6
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +5 -1
- data/test/support/assertions.rb +0 -11
- data/test/{test_helpers_test.rb → test/controller_helpers_test.rb} +2 -2
- data/test/test/integration_helpers_test.rb +32 -0
- metadata +11 -6
- data/gemfiles/Gemfile.rails-5.0-beta +0 -37
- data/gemfiles/Gemfile.rails-5.0-beta.lock +0 -199
@@ -1,64 +1,64 @@
|
|
1
1
|
GIT
|
2
2
|
remote: git://github.com/rails/rails.git
|
3
|
-
revision:
|
3
|
+
revision: 5a85938418285ab81e3db52ea102d19f95ed7a94
|
4
4
|
branch: 4-2-stable
|
5
5
|
specs:
|
6
|
-
actionmailer (4.2.
|
7
|
-
actionpack (= 4.2.
|
8
|
-
actionview (= 4.2.
|
9
|
-
activejob (= 4.2.
|
6
|
+
actionmailer (4.2.7.rc1)
|
7
|
+
actionpack (= 4.2.7.rc1)
|
8
|
+
actionview (= 4.2.7.rc1)
|
9
|
+
activejob (= 4.2.7.rc1)
|
10
10
|
mail (~> 2.5, >= 2.5.4)
|
11
11
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
12
|
-
actionpack (4.2.
|
13
|
-
actionview (= 4.2.
|
14
|
-
activesupport (= 4.2.
|
12
|
+
actionpack (4.2.7.rc1)
|
13
|
+
actionview (= 4.2.7.rc1)
|
14
|
+
activesupport (= 4.2.7.rc1)
|
15
15
|
rack (~> 1.6)
|
16
16
|
rack-test (~> 0.6.2)
|
17
17
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
19
|
-
actionview (4.2.
|
20
|
-
activesupport (= 4.2.
|
19
|
+
actionview (4.2.7.rc1)
|
20
|
+
activesupport (= 4.2.7.rc1)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubis (~> 2.7.0)
|
23
23
|
rails-dom-testing (~> 1.0, >= 1.0.5)
|
24
24
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
25
|
-
activejob (4.2.
|
26
|
-
activesupport (= 4.2.
|
25
|
+
activejob (4.2.7.rc1)
|
26
|
+
activesupport (= 4.2.7.rc1)
|
27
27
|
globalid (>= 0.3.0)
|
28
|
-
activemodel (4.2.
|
29
|
-
activesupport (= 4.2.
|
28
|
+
activemodel (4.2.7.rc1)
|
29
|
+
activesupport (= 4.2.7.rc1)
|
30
30
|
builder (~> 3.1)
|
31
|
-
activerecord (4.2.
|
32
|
-
activemodel (= 4.2.
|
33
|
-
activesupport (= 4.2.
|
31
|
+
activerecord (4.2.7.rc1)
|
32
|
+
activemodel (= 4.2.7.rc1)
|
33
|
+
activesupport (= 4.2.7.rc1)
|
34
34
|
arel (~> 6.0)
|
35
|
-
activesupport (4.2.
|
35
|
+
activesupport (4.2.7.rc1)
|
36
36
|
i18n (~> 0.7)
|
37
37
|
json (~> 1.7, >= 1.7.7)
|
38
38
|
minitest (~> 5.1)
|
39
39
|
thread_safe (~> 0.3, >= 0.3.4)
|
40
40
|
tzinfo (~> 1.1)
|
41
|
-
rails (4.2.
|
42
|
-
actionmailer (= 4.2.
|
43
|
-
actionpack (= 4.2.
|
44
|
-
actionview (= 4.2.
|
45
|
-
activejob (= 4.2.
|
46
|
-
activemodel (= 4.2.
|
47
|
-
activerecord (= 4.2.
|
48
|
-
activesupport (= 4.2.
|
41
|
+
rails (4.2.7.rc1)
|
42
|
+
actionmailer (= 4.2.7.rc1)
|
43
|
+
actionpack (= 4.2.7.rc1)
|
44
|
+
actionview (= 4.2.7.rc1)
|
45
|
+
activejob (= 4.2.7.rc1)
|
46
|
+
activemodel (= 4.2.7.rc1)
|
47
|
+
activerecord (= 4.2.7.rc1)
|
48
|
+
activesupport (= 4.2.7.rc1)
|
49
49
|
bundler (>= 1.3.0, < 2.0)
|
50
|
-
railties (= 4.2.
|
50
|
+
railties (= 4.2.7.rc1)
|
51
51
|
sprockets-rails
|
52
|
-
railties (4.2.
|
53
|
-
actionpack (= 4.2.
|
54
|
-
activesupport (= 4.2.
|
52
|
+
railties (4.2.7.rc1)
|
53
|
+
actionpack (= 4.2.7.rc1)
|
54
|
+
activesupport (= 4.2.7.rc1)
|
55
55
|
rake (>= 0.8.7)
|
56
56
|
thor (>= 0.18.1, < 2.0)
|
57
57
|
|
58
58
|
PATH
|
59
59
|
remote: ..
|
60
60
|
specs:
|
61
|
-
devise (4.0
|
61
|
+
devise (4.2.0)
|
62
62
|
bcrypt (~> 3.0)
|
63
63
|
orm_adapter (~> 0.1)
|
64
64
|
railties (>= 4.1.0, < 5.1)
|
@@ -72,25 +72,27 @@ GEM
|
|
72
72
|
bcrypt (3.1.11)
|
73
73
|
bson (3.2.6)
|
74
74
|
builder (3.2.2)
|
75
|
-
concurrent-ruby (1.0.
|
75
|
+
concurrent-ruby (1.0.2)
|
76
76
|
connection_pool (2.2.0)
|
77
77
|
erubis (2.7.0)
|
78
78
|
faraday (0.9.2)
|
79
79
|
multipart-post (>= 1.2, < 3)
|
80
80
|
globalid (0.3.6)
|
81
81
|
activesupport (>= 4.1.0)
|
82
|
-
hashie (3.4.
|
82
|
+
hashie (3.4.4)
|
83
83
|
i18n (0.7.0)
|
84
84
|
json (1.8.3)
|
85
|
-
jwt (1.5.
|
85
|
+
jwt (1.5.4)
|
86
86
|
loofah (2.0.3)
|
87
87
|
nokogiri (>= 1.5.9)
|
88
|
-
mail (2.6.
|
89
|
-
mime-types (>= 1.16, <
|
88
|
+
mail (2.6.4)
|
89
|
+
mime-types (>= 1.16, < 4)
|
90
90
|
metaclass (0.0.4)
|
91
|
-
mime-types (
|
92
|
-
|
93
|
-
|
91
|
+
mime-types (3.1)
|
92
|
+
mime-types-data (~> 3.2015)
|
93
|
+
mime-types-data (3.2016.0521)
|
94
|
+
mini_portile2 (2.1.0)
|
95
|
+
minitest (5.9.0)
|
94
96
|
mocha (1.1.0)
|
95
97
|
metaclass (~> 0.0.1)
|
96
98
|
mongoid (4.0.2)
|
@@ -102,14 +104,15 @@ GEM
|
|
102
104
|
bson (~> 3.0)
|
103
105
|
connection_pool (~> 2.0)
|
104
106
|
optionable (~> 0.2.0)
|
105
|
-
multi_json (1.
|
107
|
+
multi_json (1.12.1)
|
106
108
|
multi_xml (0.5.5)
|
107
109
|
multipart-post (2.0.0)
|
108
|
-
nokogiri (1.6.
|
109
|
-
mini_portile2 (~> 2.
|
110
|
-
|
110
|
+
nokogiri (1.6.8)
|
111
|
+
mini_portile2 (~> 2.1.0)
|
112
|
+
pkg-config (~> 1.1.7)
|
113
|
+
oauth2 (1.2.0)
|
111
114
|
faraday (>= 0.8, < 0.10)
|
112
|
-
jwt (~> 1.0
|
115
|
+
jwt (~> 1.0)
|
113
116
|
multi_json (~> 1.3)
|
114
117
|
multi_xml (~> 0.5)
|
115
118
|
rack (>= 1.2, < 3)
|
@@ -127,6 +130,7 @@ GEM
|
|
127
130
|
optionable (0.2.0)
|
128
131
|
origin (2.2.0)
|
129
132
|
orm_adapter (0.5.0)
|
133
|
+
pkg-config (1.1.7)
|
130
134
|
rack (1.6.4)
|
131
135
|
rack-openid (1.3.1)
|
132
136
|
rack (>= 1.1.0)
|
@@ -141,21 +145,21 @@ GEM
|
|
141
145
|
rails-deprecated_sanitizer (>= 1.0.1)
|
142
146
|
rails-html-sanitizer (1.0.3)
|
143
147
|
loofah (~> 2.0)
|
144
|
-
rake (11.
|
148
|
+
rake (11.2.2)
|
145
149
|
rdoc (4.2.2)
|
146
150
|
json (~> 1.4)
|
147
|
-
responders (2.
|
151
|
+
responders (2.2.0)
|
148
152
|
railties (>= 4.2.0, < 5.1)
|
149
153
|
ruby-openid (2.7.0)
|
150
|
-
sprockets (3.
|
154
|
+
sprockets (3.6.2)
|
151
155
|
concurrent-ruby (~> 1.0)
|
152
156
|
rack (> 1, < 3)
|
153
|
-
sprockets-rails (3.
|
157
|
+
sprockets-rails (3.1.1)
|
154
158
|
actionpack (>= 4.0)
|
155
159
|
activesupport (>= 4.0)
|
156
160
|
sprockets (>= 3.0.0)
|
157
161
|
sqlite3 (1.3.11)
|
158
|
-
test_after_commit (1.
|
162
|
+
test_after_commit (1.1.0)
|
159
163
|
activerecord (>= 3.2)
|
160
164
|
thor (0.19.1)
|
161
165
|
thread_safe (0.3.5)
|
@@ -177,11 +181,11 @@ DEPENDENCIES
|
|
177
181
|
devise!
|
178
182
|
jruby-openssl
|
179
183
|
mocha (~> 1.1)
|
180
|
-
mongoid (~> 4.0
|
181
|
-
omniauth
|
184
|
+
mongoid (~> 4.0)
|
185
|
+
omniauth
|
182
186
|
omniauth-facebook
|
183
|
-
omniauth-oauth2
|
184
|
-
omniauth-openid
|
187
|
+
omniauth-oauth2
|
188
|
+
omniauth-openid
|
185
189
|
rails!
|
186
190
|
rdoc
|
187
191
|
sqlite3
|
@@ -189,4 +193,4 @@ DEPENDENCIES
|
|
189
193
|
webrat (= 0.7.3)
|
190
194
|
|
191
195
|
BUNDLED WITH
|
192
|
-
1.
|
196
|
+
1.12.5
|
@@ -0,0 +1,104 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/inline'
|
3
|
+
rescue LoadError => e
|
4
|
+
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
|
5
|
+
raise e
|
6
|
+
end
|
7
|
+
|
8
|
+
gemfile(true) do
|
9
|
+
source 'https://rubygems.org'
|
10
|
+
# Activate the gem you are reporting the issue against.
|
11
|
+
gem 'rails', '~> 4.2.0'
|
12
|
+
gem 'devise', '~> 4.0'
|
13
|
+
gem 'sqlite3'
|
14
|
+
gem 'byebug'
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'rack/test'
|
18
|
+
require 'action_controller/railtie'
|
19
|
+
require 'active_record'
|
20
|
+
require 'devise/rails/routes'
|
21
|
+
require 'devise/rails/warden_compat'
|
22
|
+
|
23
|
+
ActiveRecord::Base.establish_connection( adapter: :sqlite3, database: ':memory:')
|
24
|
+
|
25
|
+
class DeviseCreateUsers < ActiveRecord::Migration
|
26
|
+
def change
|
27
|
+
create_table(:users) do |t|
|
28
|
+
t.string :email, null: false
|
29
|
+
t.string :encrypted_password, null: true
|
30
|
+
t.timestamps null: false
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Devise.setup do |config|
|
37
|
+
require 'devise/orm/active_record'
|
38
|
+
config.secret_key = 'secret_key_base'
|
39
|
+
end
|
40
|
+
|
41
|
+
class TestApp < Rails::Application
|
42
|
+
config.root = File.dirname(__FILE__)
|
43
|
+
config.session_store :cookie_store, key: 'cookie_store_key'
|
44
|
+
secrets.secret_token = 'secret_token'
|
45
|
+
secrets.secret_key_base = 'secret_key_base'
|
46
|
+
config.eager_load = false
|
47
|
+
|
48
|
+
config.middleware.use Warden::Manager do |config|
|
49
|
+
Devise.warden_config = config
|
50
|
+
end
|
51
|
+
|
52
|
+
config.logger = Logger.new($stdout)
|
53
|
+
Rails.logger = config.logger
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
Rails.application.initialize!
|
58
|
+
|
59
|
+
DeviseCreateUsers.migrate(:up)
|
60
|
+
|
61
|
+
class User < ActiveRecord::Base
|
62
|
+
devise :database_authenticatable
|
63
|
+
end
|
64
|
+
|
65
|
+
Rails.application.routes.draw do
|
66
|
+
devise_for :users
|
67
|
+
|
68
|
+
get '/' => 'test#index'
|
69
|
+
end
|
70
|
+
|
71
|
+
class ApplicationController < ActionController::Base
|
72
|
+
end
|
73
|
+
|
74
|
+
class TestController < ApplicationController
|
75
|
+
include Rails.application.routes.url_helpers
|
76
|
+
|
77
|
+
before_filter :authenticate_user!
|
78
|
+
|
79
|
+
def index
|
80
|
+
render plain: 'Home'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
require 'minitest/autorun'
|
85
|
+
|
86
|
+
class BugTest < ActionDispatch::IntegrationTest
|
87
|
+
include Rack::Test::Methods
|
88
|
+
include Warden::Test::Helpers
|
89
|
+
|
90
|
+
def test_returns_success
|
91
|
+
Warden.test_mode!
|
92
|
+
|
93
|
+
login_as User.create!(email: 'test@test.com', password: 'test123456', password_confirmation: 'test123456')
|
94
|
+
|
95
|
+
get '/'
|
96
|
+
assert last_response.ok?
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def app
|
102
|
+
Rails.application
|
103
|
+
end
|
104
|
+
end
|
data/lib/devise.rb
CHANGED
@@ -39,13 +39,18 @@ module Devise
|
|
39
39
|
autoload :Authenticatable, 'devise/strategies/authenticatable'
|
40
40
|
end
|
41
41
|
|
42
|
+
module Test
|
43
|
+
autoload :ControllerHelpers, 'devise/test/controller_helpers'
|
44
|
+
autoload :IntegrationHelpers, 'devise/test/integration_helpers'
|
45
|
+
end
|
46
|
+
|
42
47
|
# Constants which holds devise configuration for extensions. Those should
|
43
48
|
# not be modified by the "end user" (this is why they are constants).
|
44
49
|
ALL = []
|
45
|
-
CONTROLLERS =
|
46
|
-
ROUTES =
|
47
|
-
STRATEGIES =
|
48
|
-
URL_HELPERS =
|
50
|
+
CONTROLLERS = {}
|
51
|
+
ROUTES = {}
|
52
|
+
STRATEGIES = {}
|
53
|
+
URL_HELPERS = {}
|
49
54
|
|
50
55
|
# Strategies that do not require user input.
|
51
56
|
NO_INPUT = []
|
@@ -242,15 +247,22 @@ module Devise
|
|
242
247
|
mattr_accessor :clean_up_csrf_token_on_authentication
|
243
248
|
@@clean_up_csrf_token_on_authentication = true
|
244
249
|
|
250
|
+
# When false, Devise will not attempt to reload routes on eager load.
|
251
|
+
# This can reduce the time taken to boot the app but if your application
|
252
|
+
# requires the Devise mappings to be loaded during boot time the application
|
253
|
+
# won't boot properly.
|
254
|
+
mattr_accessor :reload_routes
|
255
|
+
@@reload_routes = true
|
256
|
+
|
245
257
|
# PRIVATE CONFIGURATION
|
246
258
|
|
247
259
|
# Store scopes mappings.
|
248
260
|
mattr_reader :mappings
|
249
|
-
@@mappings =
|
261
|
+
@@mappings = {}
|
250
262
|
|
251
263
|
# OmniAuth configurations.
|
252
264
|
mattr_reader :omniauth_configs
|
253
|
-
@@omniauth_configs =
|
265
|
+
@@omniauth_configs = {}
|
254
266
|
|
255
267
|
# Define a set of modules that are called when a mapping is added.
|
256
268
|
mattr_reader :helpers
|
@@ -281,7 +293,7 @@ module Devise
|
|
281
293
|
end
|
282
294
|
|
283
295
|
class Getter
|
284
|
-
def initialize
|
296
|
+
def initialize(name)
|
285
297
|
@name = name
|
286
298
|
end
|
287
299
|
|
@@ -291,12 +303,8 @@ module Devise
|
|
291
303
|
end
|
292
304
|
|
293
305
|
def self.ref(arg)
|
294
|
-
|
295
|
-
|
296
|
-
Getter.new(arg)
|
297
|
-
else
|
298
|
-
ActiveSupport::Dependencies.ref(arg)
|
299
|
-
end
|
306
|
+
ActiveSupport::Dependencies.reference(arg)
|
307
|
+
Getter.new(arg)
|
300
308
|
end
|
301
309
|
|
302
310
|
def self.available_router_name
|
@@ -417,7 +425,6 @@ module Devise
|
|
417
425
|
# config.omniauth :github, APP_ID, APP_SECRET
|
418
426
|
#
|
419
427
|
def self.omniauth(provider, *args)
|
420
|
-
@@helpers << Devise::OmniAuth::UrlHelpers
|
421
428
|
config = Devise::OmniAuth::Config.new(provider, args)
|
422
429
|
@@omniauth_configs[config.strategy_name.to_sym] = config
|
423
430
|
end
|
@@ -138,7 +138,7 @@ module Devise
|
|
138
138
|
|
139
139
|
# The main accessor for the warden proxy instance
|
140
140
|
def warden
|
141
|
-
request.env['warden']
|
141
|
+
request.env['warden'] or raise MissingWarden
|
142
142
|
end
|
143
143
|
|
144
144
|
# Return true if it's a devise_controller. false to all controllers unless
|
@@ -277,4 +277,15 @@ module Devise
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
end
|
280
|
+
|
281
|
+
class MissingWarden < StandardError
|
282
|
+
def initialize
|
283
|
+
super "Devise could not find the `Warden::Proxy` instance on your request environment.\n" + \
|
284
|
+
"Make sure that your application is loading Devise and Warden as expected and that " + \
|
285
|
+
"the `Warden::Manager` middleware is present in your middleware stack.\n" + \
|
286
|
+
"If you are seeing this on one of your tests, ensure that your tests are either " + \
|
287
|
+
"executing the Rails middleware stack or that your tests are using the `Devise::Test::ControllerHelpers` " + \
|
288
|
+
"module to inject the `request.env['warden']` object for you."
|
289
|
+
end
|
290
|
+
end
|
280
291
|
end
|
@@ -18,7 +18,7 @@ module Devise
|
|
18
18
|
|
19
19
|
# Remembers the given resource by setting up a cookie
|
20
20
|
def remember_me(resource)
|
21
|
-
return if env["devise.skip_storage"]
|
21
|
+
return if request.env["devise.skip_storage"]
|
22
22
|
scope = Devise::Mapping.find_scope!(resource)
|
23
23
|
resource.remember_me!
|
24
24
|
cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
|
@@ -12,20 +12,15 @@ module Devise
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# Sign in a user that already was authenticated. This helper is useful for logging
|
15
|
-
# users in after sign up.
|
16
|
-
#
|
17
|
-
# All options given to sign_in is passed forward to the set_user method in warden.
|
18
|
-
# The only exception is the :bypass option, which bypass warden callbacks and stores
|
19
|
-
# the user straight in session. This option is useful in cases the user is already
|
20
|
-
# signed in, but we want to refresh the credentials in session.
|
15
|
+
# users in after sign up. All options given to sign_in is passed forward
|
16
|
+
# to the set_user method in warden.
|
21
17
|
#
|
22
18
|
# Examples:
|
23
19
|
#
|
24
20
|
# sign_in :user, @user # sign_in(scope, resource)
|
25
21
|
# sign_in @user # sign_in(resource)
|
26
|
-
# sign_in @user, event: :authentication
|
27
|
-
# sign_in @user, store: false
|
28
|
-
# sign_in @user, bypass: true # sign_in(resource, options)
|
22
|
+
# sign_in @user, event: :authentication # sign_in(resource, options)
|
23
|
+
# sign_in @user, store: false # sign_in(resource, options)
|
29
24
|
#
|
30
25
|
def sign_in(resource_or_scope, *args)
|
31
26
|
options = args.extract_options!
|
@@ -35,6 +30,13 @@ module Devise
|
|
35
30
|
expire_data_after_sign_in!
|
36
31
|
|
37
32
|
if options[:bypass]
|
33
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION.strip_heredoc, caller)
|
34
|
+
[Devise] bypass option is deprecated and it will be removed in future version of Devise.
|
35
|
+
Please use bypass_sign_in method instead.
|
36
|
+
Example:
|
37
|
+
|
38
|
+
bypass_sign_in(user)
|
39
|
+
DEPRECATION
|
38
40
|
warden.session_serializer.store(resource, scope)
|
39
41
|
elsif warden.user(scope) == resource && !options.delete(:force)
|
40
42
|
# Do nothing. User already signed in and we are not forcing it.
|
@@ -44,6 +46,20 @@ module Devise
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
49
|
+
# Sign in a user bypassing the warden callbacks and stores the user
|
50
|
+
# straight in session. This option is useful in cases the user is already
|
51
|
+
# signed in, but we want to refresh the credentials in session.
|
52
|
+
#
|
53
|
+
# Examples:
|
54
|
+
#
|
55
|
+
# bypass_sign_in @user, scope: :user
|
56
|
+
# bypass_sign_in @user
|
57
|
+
def bypass_sign_in(resource, scope: nil)
|
58
|
+
scope ||= Devise::Mapping.find_scope!(resource)
|
59
|
+
expire_data_after_sign_in!
|
60
|
+
warden.session_serializer.store(resource, scope)
|
61
|
+
end
|
62
|
+
|
47
63
|
# Sign out a given user or scope. This helper is useful for signing out a user
|
48
64
|
# after deleting accounts. Returns true if there was a logout and false if there
|
49
65
|
# is no user logged in on the referred scope
|
@@ -58,7 +74,6 @@ module Devise
|
|
58
74
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
59
75
|
user = warden.user(scope: scope, run_callbacks: false) # If there is no user
|
60
76
|
|
61
|
-
warden.raw_session.inspect # Without this inspect here. The session does not clear.
|
62
77
|
warden.logout(scope)
|
63
78
|
warden.clear_strategies_cache!(scope: scope)
|
64
79
|
instance_variable_set(:"@current_#{scope}", nil)
|