clearance 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of clearance might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +1 -3
- data/Gemfile.lock +4 -28
- data/NEWS.md +12 -0
- data/README.md +8 -1
- data/Rakefile +11 -8
- data/app/controllers/clearance/passwords_controller.rb +1 -0
- data/app/controllers/clearance/sessions_controller.rb +14 -2
- data/app/controllers/clearance/users_controller.rb +15 -4
- data/bin/appraisal +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/clearance.gemspec +1 -1
- data/gemfiles/rails3.2.gemfile +1 -3
- data/gemfiles/rails4.0.gemfile +1 -3
- data/gemfiles/rails4.1.gemfile +1 -3
- data/gemfiles/rails4.2.gemfile +1 -3
- data/lib/clearance/configuration.rb +2 -0
- data/lib/clearance/session.rb +12 -6
- data/lib/clearance/version.rb +1 -1
- data/spec/acceptance/clearance_installation_spec.rb +75 -0
- data/spec/{support/app_templates → app_templates}/app/controllers/application_controller.rb +0 -0
- data/spec/{support/app_templates → app_templates}/app/models/user.rb +0 -0
- data/spec/{support/app_templates → app_templates}/config/routes.rb +0 -0
- data/spec/app_templates/testapp/Gemfile +7 -0
- data/spec/app_templates/testapp/app/controllers/home_controller.rb +5 -0
- data/spec/app_templates/testapp/config/initializers/action_mailer.rb +3 -0
- data/spec/app_templates/testapp/config/routes.rb +3 -0
- data/spec/clearance/session_spec.rb +13 -0
- data/spec/controllers/passwords_controller_spec.rb +100 -131
- data/spec/controllers/sessions_controller_spec.rb +66 -52
- data/spec/controllers/users_controller_spec.rb +47 -60
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/models/user_with_optional_password.rb +7 -0
- data/spec/dummy/application.rb +2 -0
- data/spec/factories.rb +4 -0
- data/spec/{models → password_strategies}/bcrypt_migration_from_sha1_spec.rb +1 -0
- data/spec/password_strategies/bcrypt_spec.rb +81 -0
- data/spec/password_strategies/blowfish_spec.rb +55 -0
- data/spec/password_strategies/password_strategies_spec.rb +28 -0
- data/spec/password_strategies/sha1_spec.rb +53 -0
- data/spec/support/clearance.rb +0 -16
- data/spec/support/fake_model_with_password_strategy.rb +0 -4
- data/spec/support/fake_model_without_password_strategy.rb +19 -0
- data/spec/support/generator_spec_helpers.rb +1 -1
- data/spec/support/request_with_remember_token.rb +1 -1
- data/spec/user_spec.rb +186 -0
- metadata +23 -67
- data/cucumber.yml +0 -1
- data/features/integration_with_rspec.feature +0 -23
- data/features/integration_with_test_unit.feature +0 -16
- data/features/step_definitions/configuration_steps.rb +0 -153
- data/features/step_definitions/gem_file_steps.rb +0 -15
- data/features/support/aruba.rb +0 -3
- data/features/support/env.rb +0 -27
- data/spec/models/bcrypt_spec.rb +0 -66
- data/spec/models/blowfish_spec.rb +0 -42
- data/spec/models/password_strategies_spec.rb +0 -41
- data/spec/models/sha1_spec.rb +0 -43
- data/spec/models/user_spec.rb +0 -196
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df978f0510867a2d80c064924da2b102af823b5e
|
4
|
+
data.tar.gz: be638b6207733d3a873c344f40dbbe540616805a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d3edea1ae4ce2ff2e47e6a9c747349a58978642c72b46862c303b6c0510a888cfd58668e881dfdf974369ea05c7b316a74795643c89a26059210f2f20ae8911
|
7
|
+
data.tar.gz: c31439f8e17dacb54727dd968ff6e840129ceb1e0f3fa6fb9bc99c3f4bf71a2d4bff43d98d9d22e37dba36a38d4d4bebb8e743d6a7a827cf0025e5ddde6e0b1a
|
data/Gemfile
CHANGED
@@ -4,10 +4,8 @@ gemspec
|
|
4
4
|
|
5
5
|
gem 'appraisal', '~> 1.0'
|
6
6
|
gem 'ammeter'
|
7
|
-
gem 'aruba', '~> 0.5'
|
8
7
|
gem 'bundler', '~> 1.3'
|
9
|
-
gem 'capybara', '
|
10
|
-
gem 'cucumber-rails', '~> 1.3', require: false
|
8
|
+
gem 'capybara', '>= 2.3'
|
11
9
|
gem 'database_cleaner', '~> 1.0'
|
12
10
|
gem 'factory_girl_rails', '~> 4.2'
|
13
11
|
gem 'rspec-rails', '~> 3.1'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
clearance (1.
|
4
|
+
clearance (1.8.0)
|
5
5
|
bcrypt
|
6
6
|
email_validator (~> 1.4)
|
7
7
|
rails (>= 3.1)
|
@@ -53,33 +53,15 @@ GEM
|
|
53
53
|
rake
|
54
54
|
thor (>= 0.14.0)
|
55
55
|
arel (6.0.0)
|
56
|
-
aruba (0.6.1)
|
57
|
-
childprocess (>= 0.3.6)
|
58
|
-
cucumber (>= 1.1.1)
|
59
|
-
rspec-expectations (>= 2.7.0)
|
60
56
|
bcrypt (3.1.9)
|
61
57
|
builder (3.2.2)
|
62
|
-
capybara (2.
|
58
|
+
capybara (2.4.4)
|
63
59
|
mime-types (>= 1.16)
|
64
60
|
nokogiri (>= 1.3.3)
|
65
61
|
rack (>= 1.0.0)
|
66
62
|
rack-test (>= 0.5.4)
|
67
63
|
xpath (~> 2.0)
|
68
|
-
childprocess (0.5.5)
|
69
|
-
ffi (~> 1.0, >= 1.0.11)
|
70
64
|
coderay (1.1.0)
|
71
|
-
cucumber (1.3.18)
|
72
|
-
builder (>= 2.1.2)
|
73
|
-
diff-lcs (>= 1.1.3)
|
74
|
-
gherkin (~> 2.12)
|
75
|
-
multi_json (>= 1.7.5, < 2.0)
|
76
|
-
multi_test (>= 0.1.1)
|
77
|
-
cucumber-rails (1.4.2)
|
78
|
-
capybara (>= 1.1.2, < 3)
|
79
|
-
cucumber (>= 1.3.8, < 2)
|
80
|
-
mime-types (>= 1.16, < 3)
|
81
|
-
nokogiri (~> 1.5)
|
82
|
-
rails (>= 3, < 5)
|
83
65
|
database_cleaner (1.3.0)
|
84
66
|
diff-lcs (1.2.5)
|
85
67
|
email_validator (1.5.0)
|
@@ -90,9 +72,6 @@ GEM
|
|
90
72
|
factory_girl_rails (4.5.0)
|
91
73
|
factory_girl (~> 4.5.0)
|
92
74
|
railties (>= 3.0.0)
|
93
|
-
ffi (1.9.6)
|
94
|
-
gherkin (2.12.2)
|
95
|
-
multi_json (~> 1.3)
|
96
75
|
globalid (0.3.0)
|
97
76
|
activesupport (>= 4.1.0)
|
98
77
|
hike (1.2.3)
|
@@ -107,7 +86,6 @@ GEM
|
|
107
86
|
mini_portile (0.6.2)
|
108
87
|
minitest (5.5.0)
|
109
88
|
multi_json (1.10.1)
|
110
|
-
multi_test (0.1.1)
|
111
89
|
nokogiri (1.6.5)
|
112
90
|
mini_portile (~> 0.6.0)
|
113
91
|
pry (0.10.1)
|
@@ -115,7 +93,7 @@ GEM
|
|
115
93
|
method_source (~> 0.8.1)
|
116
94
|
slop (~> 3.4)
|
117
95
|
rack (1.6.0)
|
118
|
-
rack-test (0.6.
|
96
|
+
rack-test (0.6.3)
|
119
97
|
rack (>= 1.0)
|
120
98
|
rails (4.2.0)
|
121
99
|
actionmailer (= 4.2.0)
|
@@ -186,11 +164,9 @@ PLATFORMS
|
|
186
164
|
DEPENDENCIES
|
187
165
|
ammeter
|
188
166
|
appraisal (~> 1.0)
|
189
|
-
aruba (~> 0.5)
|
190
167
|
bundler (~> 1.3)
|
191
|
-
capybara (
|
168
|
+
capybara (>= 2.3)
|
192
169
|
clearance!
|
193
|
-
cucumber-rails (~> 1.3)
|
194
170
|
database_cleaner (~> 1.0)
|
195
171
|
factory_girl_rails (~> 4.2)
|
196
172
|
pry
|
data/NEWS.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
Thank you to all the [contributors](https://github.com/thoughtbot/clearance/graphs/contributors)!
|
2
2
|
|
3
|
+
New for 1.8.0 (January 23, 2015)
|
4
|
+
* Fixed an issue that would cause sites that are still using the deprecated
|
5
|
+
`authorize` filter to enter a redirect loop when redirecting to the sign in
|
6
|
+
path.
|
7
|
+
* The Clearance remember token cookie name is now customizable via
|
8
|
+
`Clearance.configuration.cookie_name`.
|
9
|
+
* Signed in users that attempt to visit the sign in path are now redirected. The
|
10
|
+
redirect URL defaults to the same URL used for the redirect after sign in, but
|
11
|
+
can be customized by overriding `passwords_controller#url_for_signed_in_users`
|
12
|
+
* `users_controller#avoid_sign_in` is now deprecated in favor of
|
13
|
+
`redirect_signed_in_users` which is more accurately named.
|
14
|
+
|
3
15
|
New for 1.7.0 (January, 8, 2015)
|
4
16
|
* The `authorize` filter has been deprecated in favor of `require_login`. Update
|
5
17
|
all reference to the filter including any calls to `skip_before_filter` or
|
data/README.md
CHANGED
@@ -10,7 +10,12 @@ Clearance was extracted out of [Airbrake](http://airbrake.io/). It is intended
|
|
10
10
|
to be small, simple, and well-tested. It is intended to be easy to override
|
11
11
|
defaults.
|
12
12
|
|
13
|
-
|
13
|
+
Please use [GitHub Issues] to report bugs. If you have a question about the
|
14
|
+
library, please use the `clearance` tag on [Stack Overflow]. This tag is
|
15
|
+
monitored by contributors.
|
16
|
+
|
17
|
+
[GitHub Issues]: https://github.com/thoughtbot/clearance/issues
|
18
|
+
[Stack Overflow]: http://stackoverflow.com/questions/tagged/clearance
|
14
19
|
|
15
20
|
Read [CONTRIBUTING.md](/CONTRIBUTING.md) to contribute.
|
16
21
|
|
@@ -59,6 +64,7 @@ Clearance.configure do |config|
|
|
59
64
|
config.allow_sign_up = true
|
60
65
|
config.cookie_domain = '.example.com'
|
61
66
|
config.cookie_expiration = lambda { |cookies| 1.year.from_now.utc }
|
67
|
+
config.cookie_name = 'remember_token'
|
62
68
|
config.cookie_path = '/'
|
63
69
|
config.routes = true
|
64
70
|
config.httponly = false
|
@@ -216,6 +222,7 @@ All of these controller methods redirect to `'/'` by default:
|
|
216
222
|
|
217
223
|
passwords#url_after_update
|
218
224
|
sessions#url_after_create
|
225
|
+
sessions#url_for_signed_in_users
|
219
226
|
users#url_after_create
|
220
227
|
application#url_after_denied_access_when_signed_in
|
221
228
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
require "rubygems"
|
3
2
|
require "bundler/setup"
|
4
3
|
require "bundler/gem_tasks"
|
5
4
|
|
6
5
|
require "rake"
|
7
|
-
require "cucumber/rake/task"
|
8
6
|
require "rspec/core/rake_task"
|
9
7
|
|
10
8
|
namespace :dummy do
|
@@ -12,12 +10,17 @@ namespace :dummy do
|
|
12
10
|
Dummy::Application.load_tasks
|
13
11
|
end
|
14
12
|
|
15
|
-
desc "
|
16
|
-
|
13
|
+
desc "Run specs other than spec/acceptance"
|
14
|
+
RSpec::Core::RakeTask.new("spec") do |task|
|
15
|
+
task.exclude_pattern = "spec/acceptance/**/*_spec.rb"
|
16
|
+
task.verbose = false
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
desc "Run acceptance specs in spec/acceptance"
|
20
|
+
RSpec::Core::RakeTask.new("spec:acceptance") do |task|
|
21
|
+
task.pattern = "spec/acceptance/**/*_spec.rb"
|
22
|
+
task.verbose = false
|
21
23
|
end
|
22
24
|
|
23
|
-
|
25
|
+
desc "Run the specs and acceptance tests"
|
26
|
+
task default: %w(spec spec:acceptance)
|
@@ -2,6 +2,7 @@ require 'active_support/deprecation'
|
|
2
2
|
|
3
3
|
class Clearance::PasswordsController < Clearance::BaseController
|
4
4
|
skip_before_filter :require_login, only: [:create, :edit, :new, :update]
|
5
|
+
skip_before_filter :authorize, only: [:create, :edit, :new, :update]
|
5
6
|
before_filter :forbid_missing_token, only: [:edit, :update]
|
6
7
|
before_filter :forbid_non_existent_user, only: [:edit, :update]
|
7
8
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Clearance::SessionsController < Clearance::BaseController
|
2
|
+
before_filter :redirect_signed_in_users, only: [:new]
|
2
3
|
skip_before_filter :require_login, only: [:create, :new, :destroy]
|
4
|
+
skip_before_filter :authorize, only: [:create, :new, :destroy]
|
3
5
|
protect_from_forgery except: :create
|
4
6
|
|
5
7
|
def create
|
@@ -10,7 +12,7 @@ class Clearance::SessionsController < Clearance::BaseController
|
|
10
12
|
redirect_back_or url_after_create
|
11
13
|
else
|
12
14
|
flash.now.notice = status.failure_message
|
13
|
-
render template:
|
15
|
+
render template: "sessions/new", status: :unauthorized
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -21,11 +23,17 @@ class Clearance::SessionsController < Clearance::BaseController
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def new
|
24
|
-
render template:
|
26
|
+
render template: "sessions/new"
|
25
27
|
end
|
26
28
|
|
27
29
|
private
|
28
30
|
|
31
|
+
def redirect_signed_in_users
|
32
|
+
if signed_in?
|
33
|
+
redirect_to url_for_signed_in_users
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
def url_after_create
|
30
38
|
Clearance.configuration.redirect_url
|
31
39
|
end
|
@@ -33,4 +41,8 @@ class Clearance::SessionsController < Clearance::BaseController
|
|
33
41
|
def url_after_destroy
|
34
42
|
sign_in_url
|
35
43
|
end
|
44
|
+
|
45
|
+
def url_for_signed_in_users
|
46
|
+
url_after_create
|
47
|
+
end
|
36
48
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class Clearance::UsersController < Clearance::BaseController
|
2
|
+
before_filter :redirect_signed_in_users, only: [:create, :new]
|
2
3
|
skip_before_filter :require_login, only: [:create, :new]
|
3
|
-
|
4
|
+
skip_before_filter :authorize, only: [:create, :new]
|
4
5
|
|
5
6
|
def new
|
6
7
|
@user = user_from_params
|
7
|
-
render template:
|
8
|
+
render template: "users/new"
|
8
9
|
end
|
9
10
|
|
10
11
|
def create
|
@@ -14,14 +15,24 @@ class Clearance::UsersController < Clearance::BaseController
|
|
14
15
|
sign_in @user
|
15
16
|
redirect_back_or url_after_create
|
16
17
|
else
|
17
|
-
render template:
|
18
|
+
render template: "users/new"
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
24
|
def avoid_sign_in
|
24
|
-
|
25
|
+
warn "[DEPRECATION] Clearance's `avoid_sign_in` before_filter is " +
|
26
|
+
"deprecated. Use `redirect_signed_in_users` instead. " +
|
27
|
+
"Be sure to update any instances of `skip_before_filter :avoid_sign_in`" +
|
28
|
+
" or `skip_before_action :avoid_sign_in` as well"
|
29
|
+
redirect_signed_in_users
|
30
|
+
end
|
31
|
+
|
32
|
+
def redirect_signed_in_users
|
33
|
+
if signed_in?
|
34
|
+
redirect_to Clearance.configuration.redirect_url
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
38
|
def url_after_create
|
data/bin/appraisal
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'appraisal' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('appraisal', 'appraisal')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/clearance.gemspec
CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.require_paths = ['lib']
|
38
38
|
s.required_ruby_version = Gem::Requirement.new('>= 1.9.2')
|
39
39
|
s.summary = 'Rails authentication & authorization with email & password.'
|
40
|
-
s.test_files = `git ls-files -- {
|
40
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
41
41
|
s.version = Clearance::VERSION
|
42
42
|
end
|
data/gemfiles/rails3.2.gemfile
CHANGED
@@ -4,10 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 1.0"
|
6
6
|
gem "ammeter"
|
7
|
-
gem "aruba", "~> 0.5"
|
8
7
|
gem "bundler", "~> 1.3"
|
9
|
-
gem "capybara", "
|
10
|
-
gem "cucumber-rails", "~> 1.3", :require => false
|
8
|
+
gem "capybara", ">= 2.3"
|
11
9
|
gem "database_cleaner", "~> 1.0"
|
12
10
|
gem "factory_girl_rails", "~> 4.2"
|
13
11
|
gem "rspec-rails", "~> 3.1"
|
data/gemfiles/rails4.0.gemfile
CHANGED
@@ -4,10 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 1.0"
|
6
6
|
gem "ammeter"
|
7
|
-
gem "aruba", "~> 0.5"
|
8
7
|
gem "bundler", "~> 1.3"
|
9
|
-
gem "capybara", "
|
10
|
-
gem "cucumber-rails", "~> 1.3", :require => false
|
8
|
+
gem "capybara", ">= 2.3"
|
11
9
|
gem "database_cleaner", "~> 1.0"
|
12
10
|
gem "factory_girl_rails", "~> 4.2"
|
13
11
|
gem "rspec-rails", "~> 3.1"
|
data/gemfiles/rails4.1.gemfile
CHANGED
@@ -4,10 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 1.0"
|
6
6
|
gem "ammeter"
|
7
|
-
gem "aruba", "~> 0.5"
|
8
7
|
gem "bundler", "~> 1.3"
|
9
|
-
gem "capybara", "
|
10
|
-
gem "cucumber-rails", "~> 1.3", :require => false
|
8
|
+
gem "capybara", ">= 2.3"
|
11
9
|
gem "database_cleaner", "~> 1.0"
|
12
10
|
gem "factory_girl_rails", "~> 4.2"
|
13
11
|
gem "rspec-rails", "~> 3.1"
|
data/gemfiles/rails4.2.gemfile
CHANGED
@@ -4,10 +4,8 @@ source "https://rubygems.org"
|
|
4
4
|
|
5
5
|
gem "appraisal", "~> 1.0"
|
6
6
|
gem "ammeter"
|
7
|
-
gem "aruba", "~> 0.5"
|
8
7
|
gem "bundler", "~> 1.3"
|
9
|
-
gem "capybara", "
|
10
|
-
gem "cucumber-rails", "~> 1.3", :require => false
|
8
|
+
gem "capybara", ">= 2.3"
|
11
9
|
gem "database_cleaner", "~> 1.0"
|
12
10
|
gem "factory_girl_rails", "~> 4.2"
|
13
11
|
gem "rspec-rails", "~> 3.1"
|
@@ -5,6 +5,7 @@ module Clearance
|
|
5
5
|
attr_accessor \
|
6
6
|
:cookie_domain,
|
7
7
|
:cookie_expiration,
|
8
|
+
:cookie_name,
|
8
9
|
:cookie_path,
|
9
10
|
:httponly,
|
10
11
|
:mailer_sender,
|
@@ -18,6 +19,7 @@ module Clearance
|
|
18
19
|
@allow_sign_up = true
|
19
20
|
@cookie_expiration = ->(cookies) { 1.year.from_now.utc }
|
20
21
|
@cookie_path = '/'
|
22
|
+
@cookie_name = "remember_token"
|
21
23
|
@httponly = false
|
22
24
|
@mailer_sender = 'reply@example.com'
|
23
25
|
@redirect_url = '/'
|
data/lib/clearance/session.rb
CHANGED
@@ -2,8 +2,6 @@ require 'clearance/default_sign_in_guard'
|
|
2
2
|
|
3
3
|
module Clearance
|
4
4
|
class Session
|
5
|
-
REMEMBER_TOKEN_COOKIE = 'remember_token'.freeze
|
6
|
-
|
7
5
|
def initialize(env)
|
8
6
|
@env = env
|
9
7
|
@current_user = nil
|
@@ -12,7 +10,11 @@ module Clearance
|
|
12
10
|
|
13
11
|
def add_cookie_to_headers(headers)
|
14
12
|
if cookie_value[:value].present?
|
15
|
-
Rack::Utils.set_cookie_header!(
|
13
|
+
Rack::Utils.set_cookie_header!(
|
14
|
+
headers,
|
15
|
+
remember_token_cookie,
|
16
|
+
cookie_value
|
17
|
+
)
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -29,7 +31,7 @@ module Clearance
|
|
29
31
|
status = run_sign_in_stack
|
30
32
|
|
31
33
|
if status.success?
|
32
|
-
cookies[
|
34
|
+
cookies[remember_token_cookie] = user && user.remember_token
|
33
35
|
else
|
34
36
|
@current_user = nil
|
35
37
|
end
|
@@ -45,7 +47,7 @@ module Clearance
|
|
45
47
|
end
|
46
48
|
|
47
49
|
@current_user = nil
|
48
|
-
cookies.delete
|
50
|
+
cookies.delete remember_token_cookie
|
49
51
|
end
|
50
52
|
|
51
53
|
def signed_in?
|
@@ -63,7 +65,7 @@ module Clearance
|
|
63
65
|
end
|
64
66
|
|
65
67
|
def remember_token
|
66
|
-
cookies[
|
68
|
+
cookies[remember_token_cookie]
|
67
69
|
end
|
68
70
|
|
69
71
|
def remember_token_expires
|
@@ -78,6 +80,10 @@ module Clearance
|
|
78
80
|
end
|
79
81
|
end
|
80
82
|
|
83
|
+
def remember_token_cookie
|
84
|
+
Clearance.configuration.cookie_name.freeze
|
85
|
+
end
|
86
|
+
|
81
87
|
def expires_configuration
|
82
88
|
Clearance.configuration.cookie_expiration
|
83
89
|
end
|