clearance 1.2.1 → 1.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 clearance might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/NEWS.md +5 -1
- data/features/add_migrations_to_project.feature +4 -3
- data/features/step_definitions/configuration_steps.rb +19 -14
- data/lib/clearance/token.rb +7 -0
- data/lib/clearance/user.rb +3 -2
- data/lib/clearance/version.rb +1 -1
- data/lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb +10 -0
- data/spec/clearance/token_spec.rb +10 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd3a11e206f30f451d54a86f708384fa70347724
|
4
|
+
data.tar.gz: e5b0a43cb7152178ca45351686e151bc1a01dd69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72f6f66e1473b220645672aa7fa324544f71217e298f05e85f545e898ba92eb1f7c2e056ed518c136aa5d2dbeda3ad313e72de3bb91f19cc21f929df2487860a
|
7
|
+
data.tar.gz: de1749e0f05fa69744648c32c6358c0adf4a14da4c9c9dabeec723d847c2cd7321c590d8a1c7f1154106e09d7e113d85bbb97acda2e23142ce61ba2a12b49576
|
data/Gemfile.lock
CHANGED
data/NEWS.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
Thank you to all the [contributors](https://github.com/thoughtbot/clearance/graphs/contributors)!
|
2
2
|
|
3
|
+
New for 1.3.0 (March 14, 2014)
|
4
|
+
* Installing Clearance with an existing User model will now create a migration
|
5
|
+
that includes adding remember tokens to all existing user records.
|
6
|
+
|
3
7
|
New for 1.2.1 (March 6, 2014):
|
4
8
|
* Query string is now included in the redirect URL when Clearance redirects to a
|
5
9
|
previously stored URL.
|
@@ -19,7 +23,7 @@ New for 1.1.0 (November 21, 2013):
|
|
19
23
|
|
20
24
|
* Validate email with `EmailValidator` [strict mode][strict].
|
21
25
|
* The `cookie_expiration` configuration lambda can now be called with a
|
22
|
-
`cookies` parameter.
|
26
|
+
`cookies` parameter. Allows the Clearance cookie expiration to be set
|
23
27
|
according to the value of another cookie (such as `remember_me`).
|
24
28
|
* A `cookie_expiration` lambda that does not accept this `cookies`
|
25
29
|
parameter has been deprecated.
|
@@ -14,14 +14,15 @@ Feature: add migrations to the project
|
|
14
14
|
|
15
15
|
Scenario: Users table without clearance fields exists in the database
|
16
16
|
When I install dependencies
|
17
|
-
And I create a simple
|
18
|
-
And I
|
17
|
+
And I create a simple user model
|
18
|
+
And I add an existing user
|
19
19
|
And I successfully run `bundle exec rails generate clearance:install`
|
20
|
-
And I successfully run `
|
20
|
+
And I successfully run `bundle exec rake db:migrate`
|
21
21
|
Then the output should contain:
|
22
22
|
"""
|
23
23
|
add_clearance_to_users.rb
|
24
24
|
"""
|
25
|
+
And the existing user should have a remember token
|
25
26
|
|
26
27
|
Scenario: Users table with clearance fields exists in the database
|
27
28
|
When I install dependencies
|
@@ -89,21 +89,26 @@ When /^I configure test-unit$/ do
|
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
|
-
When /^I create a simple
|
92
|
+
When /^I create a simple user model$/ do
|
93
93
|
steps %Q{
|
94
|
-
When I
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
94
|
+
When I successfully run `rails generate model user email:string name:string`
|
95
|
+
And I successfully run `bundle exec rake db:migrate`
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
When /^I add an existing user$/ do
|
100
|
+
command = %q{rails runner "User.create!(email: 'a@b.com', name: 'foo')"}
|
101
|
+
|
102
|
+
steps %Q{
|
103
|
+
When I successfully run `#{command}`
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
When /existing user should have a remember token$/ do
|
108
|
+
command = 'rails runner "exit(1) unless User.first.remember_token"'
|
109
|
+
|
110
|
+
steps %Q{
|
111
|
+
When I successfully run `#{command}`
|
107
112
|
}
|
108
113
|
end
|
109
114
|
|
data/lib/clearance/user.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'digest/sha1'
|
2
2
|
require 'email_validator'
|
3
|
+
require 'clearance/token'
|
3
4
|
|
4
5
|
module Clearance
|
5
6
|
module User
|
@@ -102,11 +103,11 @@ module Clearance
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def generate_confirmation_token
|
105
|
-
self.confirmation_token =
|
106
|
+
self.confirmation_token = Clearance::Token.new
|
106
107
|
end
|
107
108
|
|
108
109
|
def generate_remember_token
|
109
|
-
self.remember_token =
|
110
|
+
self.remember_token = Clearance::Token.new
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
data/lib/clearance/version.rb
CHANGED
@@ -9,6 +9,16 @@ class AddClearanceToUsers < ActiveRecord::Migration
|
|
9
9
|
<% config[:new_indexes].values.each do |index| -%>
|
10
10
|
<%= index %>
|
11
11
|
<% end -%>
|
12
|
+
|
13
|
+
users = select_all('SELECT id FROM users WHERE remember_token IS NULL')
|
14
|
+
|
15
|
+
users.each do |user|
|
16
|
+
update <<-SQL
|
17
|
+
UPDATE users
|
18
|
+
SET remember_token = '#{Clearance::Token.new}'
|
19
|
+
WHERE id = '#{user['id']}'
|
20
|
+
SQL
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
def self.down
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
@@ -25,7 +25,7 @@ authors:
|
|
25
25
|
autorequire:
|
26
26
|
bindir: bin
|
27
27
|
cert_chain: []
|
28
|
-
date: 2014-03-
|
28
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
29
29
|
dependencies:
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: bcrypt
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/clearance/testing/config/routes.rb
|
145
145
|
- lib/clearance/testing/deny_access_matcher.rb
|
146
146
|
- lib/clearance/testing/helpers.rb
|
147
|
+
- lib/clearance/token.rb
|
147
148
|
- lib/clearance/user.rb
|
148
149
|
- lib/clearance/version.rb
|
149
150
|
- lib/generators/clearance/install/install_generator.rb
|
@@ -175,6 +176,7 @@ files:
|
|
175
176
|
- spec/clearance/session_spec.rb
|
176
177
|
- spec/clearance/sign_in_guard_spec.rb
|
177
178
|
- spec/clearance/testing/helpers_spec.rb
|
179
|
+
- spec/clearance/token_spec.rb
|
178
180
|
- spec/configuration_spec.rb
|
179
181
|
- spec/controllers/apis_controller_spec.rb
|
180
182
|
- spec/controllers/flashes_controller_spec.rb
|
@@ -238,6 +240,7 @@ test_files:
|
|
238
240
|
- spec/clearance/session_spec.rb
|
239
241
|
- spec/clearance/sign_in_guard_spec.rb
|
240
242
|
- spec/clearance/testing/helpers_spec.rb
|
243
|
+
- spec/clearance/token_spec.rb
|
241
244
|
- spec/configuration_spec.rb
|
242
245
|
- spec/controllers/apis_controller_spec.rb
|
243
246
|
- spec/controllers/flashes_controller_spec.rb
|