thoughtbot-clearance 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +5 -4
- data/Rakefile +2 -3
- data/TODO.textile +1 -1
- data/generators/clearance/templates/db/migrate/create_users_with_clearance_columns.rb +2 -2
- data/generators/clearance/templates/db/migrate/update_users_with_clearance_columns.rb +2 -2
- data/lib/clearance/app/controllers/application_controller.rb +4 -2
- data/lib/clearance/app/models/user.rb +6 -2
- data/lib/clearance/test/functional/passwords_controller_test.rb +1 -1
- data/lib/clearance/test/functional/users_controller_test.rb +0 -13
- data/lib/clearance/test/unit/user_test.rb +5 -1
- metadata +43 -43
data/README.textile
CHANGED
@@ -153,9 +153,9 @@ To specify where to redirect a user (say you want to have a sign in form on ever
|
|
153
153
|
|
154
154
|
<% form_for :session, :url => session_path(:return_to => request.request_uri) do |form| %>
|
155
155
|
|
156
|
-
h2. Hooks: url_after_create, url_after_destroy
|
156
|
+
h2. Hooks: url_after_create, url_after_update, url_after_destroy
|
157
157
|
|
158
|
-
Actions that redirect (create and destroy) in Clearance controllers are customizable. If you want to redirect a user to a specific route after signing in, overwrite the "url_after_create" method in the SessionsController:
|
158
|
+
Actions that redirect (create, update, and destroy) in Clearance controllers are customizable. If you want to redirect a user to a specific route after signing in, overwrite the "url_after_create" method in the SessionsController:
|
159
159
|
|
160
160
|
class SessionsController < ApplicationController
|
161
161
|
include Clearance::App::Controllers::SessionsController
|
@@ -173,6 +173,7 @@ There are similar methods in other controllers as well:
|
|
173
173
|
SessionsController#url_after_create (sign in)
|
174
174
|
SessionsController#url_after_destroy (sign out)
|
175
175
|
PasswordsController#url_after_create (password request)
|
176
|
+
PasswordsController#url_after_update (password)
|
176
177
|
ConfirmationsController#url_after_create (confirmation)
|
177
178
|
|
178
179
|
h2. Hooks: sign_user_in
|
@@ -197,8 +198,8 @@ h2. Authors
|
|
197
198
|
|
198
199
|
* thoughtbot, inc.
|
199
200
|
* Dan Croak
|
200
|
-
* Jason Morrison
|
201
201
|
* Mike Burns
|
202
|
+
* Jason Morrison
|
203
|
+
* Eugene Bolshakov
|
202
204
|
* Josh Nichols
|
203
205
|
* Mike Breen
|
204
|
-
* Eugene Bolshakov
|
data/Rakefile
CHANGED
@@ -20,7 +20,6 @@ namespace :generator do
|
|
20
20
|
|
21
21
|
FileUtils.rm_rf("test/rails_root/db/migrate")
|
22
22
|
FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
|
23
|
-
system "cp generators/clearance/templates/config/routes.rb test/rails_root/config"
|
24
23
|
system "mkdir -p test/rails_root/vendor/plugins/clearance"
|
25
24
|
system "cp -R generators test/rails_root/vendor/plugins/clearance"
|
26
25
|
end
|
@@ -36,8 +35,8 @@ task :default => 'test:all'
|
|
36
35
|
|
37
36
|
gem_spec = Gem::Specification.new do |gem_spec|
|
38
37
|
gem_spec.name = "clearance"
|
39
|
-
gem_spec.version = "0.4.
|
40
|
-
gem_spec.summary = "
|
38
|
+
gem_spec.version = "0.4.1"
|
39
|
+
gem_spec.summary = "Rails authentication for developers who write tests."
|
41
40
|
gem_spec.email = "support@thoughtbot.com"
|
42
41
|
gem_spec.homepage = "http://github.com/thoughtbot/clearance"
|
43
42
|
gem_spec.description = "Simple, complete Rails authentication scheme."
|
data/TODO.textile
CHANGED
@@ -3,6 +3,6 @@
|
|
3
3
|
# refactor password controller test
|
4
4
|
# existing_user? methods ... if salt is wrong, user may not be found b/c of invalid credentials. is :not_found the correct code to return in that use case? if not, method probably needs to be split into another conditional.
|
5
5
|
# document shoulda macros
|
6
|
-
# will SHA512 hashes fit in all the places they are being used? (db columns, sessions) 128 characters
|
6
|
+
# will SHA512 hashes fit in all the places they are being used? (db columns - fit now, sessions) 128 characters
|
7
7
|
|
8
8
|
http://adam.speaksoutofturn.com/post/57615195/entication-vs-orization
|
@@ -2,8 +2,8 @@ class CreateOrUpdateUsersWithClearanceColumns < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
3
3
|
create_table(:users) do |t|
|
4
4
|
t.string :email
|
5
|
-
t.string :encrypted_password, :limit =>
|
6
|
-
t.string :salt, :limit =>
|
5
|
+
t.string :encrypted_password, :limit => 128
|
6
|
+
t.string :salt, :limit => 128
|
7
7
|
t.string :remember_token
|
8
8
|
t.datetime :remember_token_expires_at
|
9
9
|
t.boolean :email_confirmed, :default => false, :null => false
|
@@ -4,8 +4,8 @@ class CreateOrUpdateUsersWithClearanceColumns < ActiveRecord::Migration
|
|
4
4
|
existing_columns = ActiveRecord::Base.connection.columns(:users).collect { |each| each.name }
|
5
5
|
columns = [
|
6
6
|
[:email, 't.string :email'],
|
7
|
-
[:encrypted_password, 't.string :encrypted_password, :limit =>
|
8
|
-
[:salt, 't.string :salt, :limit =>
|
7
|
+
[:encrypted_password, 't.string :encrypted_password, :limit => 180'],
|
8
|
+
[:salt, 't.string :salt, :limit => 180'],
|
9
9
|
[:remember_token, 't.string :remember_token'],
|
10
10
|
[:remember_token_expires_at, 't.datetime :remember_token_expires_at'],
|
11
11
|
[:email_confirmed, 't.boolean :email_confirmed, :default => false, :null => false']
|
@@ -5,12 +5,14 @@ module Clearance
|
|
5
5
|
|
6
6
|
def self.included(controller)
|
7
7
|
controller.class_eval do
|
8
|
-
|
8
|
+
|
9
9
|
helper_method :current_user
|
10
10
|
helper_method :signed_in?
|
11
|
+
|
12
|
+
hide_action :current_user, :signed_in?
|
11
13
|
|
12
14
|
def current_user
|
13
|
-
user_from_session || user_from_cookie
|
15
|
+
@_current_user ||= (user_from_session || user_from_cookie)
|
14
16
|
end
|
15
17
|
|
16
18
|
def signed_in?
|
@@ -29,7 +29,7 @@ module Clearance
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def encrypt(string)
|
32
|
-
|
32
|
+
hash("--#{salt}--#{string}--")
|
33
33
|
end
|
34
34
|
|
35
35
|
def remember?
|
@@ -56,10 +56,14 @@ module Clearance
|
|
56
56
|
end
|
57
57
|
|
58
58
|
protected
|
59
|
+
|
60
|
+
def hash(string)
|
61
|
+
Digest::SHA512.hexdigest(string)
|
62
|
+
end
|
59
63
|
|
60
64
|
def initialize_salt
|
61
65
|
if new_record?
|
62
|
-
self.salt =
|
66
|
+
self.salt = hash("--#{Time.now.utc.to_s}--#{password}--")
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
@@ -50,19 +50,6 @@ module Clearance
|
|
50
50
|
|
51
51
|
should_create_user_successfully
|
52
52
|
end
|
53
|
-
|
54
|
-
context "Given valid email confirmation attributes when creating a new user" do
|
55
|
-
setup do
|
56
|
-
user_attributes = Factory.attributes_for(:email_confirmed_user)
|
57
|
-
post :create, :user => user_attributes
|
58
|
-
end
|
59
|
-
|
60
|
-
should_create_user_successfully
|
61
|
-
|
62
|
-
should "not confirm email" do
|
63
|
-
assert ! assigns(:user).email_confirmed
|
64
|
-
end
|
65
|
-
end
|
66
53
|
end
|
67
54
|
|
68
55
|
signed_in_user_context do
|
@@ -5,11 +5,15 @@ module Clearance
|
|
5
5
|
|
6
6
|
def self.included(unit_test)
|
7
7
|
unit_test.class_eval do
|
8
|
+
|
9
|
+
should_protect_attributes :email_confirmed,
|
10
|
+
:salt, :encrypted_password,
|
11
|
+
:remember_token, :remember_token_expires_at
|
8
12
|
|
9
13
|
# registering
|
10
14
|
|
11
15
|
context "When registering" do
|
12
|
-
should_require_attributes :email
|
16
|
+
should_require_attributes :email, :password
|
13
17
|
should_allow_values_for :email, "foo@example.com"
|
14
18
|
should_not_allow_values_for :email, "foo"
|
15
19
|
should_not_allow_values_for :email, "example.com"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thoughtbot-clearance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot, inc.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2009-01-
|
18
|
+
date: 2009-01-26 21:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,30 +28,26 @@ extensions: []
|
|
28
28
|
extra_rdoc_files: []
|
29
29
|
|
30
30
|
files:
|
31
|
-
- LICENSE
|
32
31
|
- Rakefile
|
33
32
|
- README.textile
|
33
|
+
- LICENSE
|
34
34
|
- TODO.textile
|
35
35
|
- generators/clearance
|
36
|
-
- generators/clearance/clearance_generator.rb
|
37
|
-
- generators/clearance/lib
|
38
|
-
- generators/clearance/lib/insert_commands.rb
|
39
|
-
- generators/clearance/lib/rake_commands.rb
|
40
36
|
- generators/clearance/templates
|
37
|
+
- generators/clearance/templates/README
|
38
|
+
- generators/clearance/templates/test
|
39
|
+
- generators/clearance/templates/test/factories
|
40
|
+
- generators/clearance/templates/test/factories/clearance.rb
|
41
|
+
- generators/clearance/templates/test/functional
|
42
|
+
- generators/clearance/templates/test/functional/confirmations_controller_test.rb
|
43
|
+
- generators/clearance/templates/test/functional/passwords_controller_test.rb
|
44
|
+
- generators/clearance/templates/test/functional/sessions_controller_test.rb
|
45
|
+
- generators/clearance/templates/test/functional/users_controller_test.rb
|
46
|
+
- generators/clearance/templates/test/unit
|
47
|
+
- generators/clearance/templates/test/unit/clearance_mailer_test.rb
|
48
|
+
- generators/clearance/templates/test/unit/user_test.rb
|
41
49
|
- generators/clearance/templates/app
|
42
|
-
- generators/clearance/templates/app/controllers
|
43
|
-
- generators/clearance/templates/app/controllers/application.rb
|
44
|
-
- generators/clearance/templates/app/controllers/confirmations_controller.rb
|
45
|
-
- generators/clearance/templates/app/controllers/passwords_controller.rb
|
46
|
-
- generators/clearance/templates/app/controllers/sessions_controller.rb
|
47
|
-
- generators/clearance/templates/app/controllers/users_controller.rb
|
48
|
-
- generators/clearance/templates/app/models
|
49
|
-
- generators/clearance/templates/app/models/clearance_mailer.rb
|
50
|
-
- generators/clearance/templates/app/models/user.rb
|
51
50
|
- generators/clearance/templates/app/views
|
52
|
-
- generators/clearance/templates/app/views/clearance_mailer
|
53
|
-
- generators/clearance/templates/app/views/clearance_mailer/change_password.html.erb
|
54
|
-
- generators/clearance/templates/app/views/clearance_mailer/confirmation.html.erb
|
55
51
|
- generators/clearance/templates/app/views/passwords
|
56
52
|
- generators/clearance/templates/app/views/passwords/edit.html.erb
|
57
53
|
- generators/clearance/templates/app/views/passwords/new.html.erb
|
@@ -61,44 +57,48 @@ files:
|
|
61
57
|
- generators/clearance/templates/app/views/users/_form.html.erb
|
62
58
|
- generators/clearance/templates/app/views/users/edit.html.erb
|
63
59
|
- generators/clearance/templates/app/views/users/new.html.erb
|
60
|
+
- generators/clearance/templates/app/views/clearance_mailer
|
61
|
+
- generators/clearance/templates/app/views/clearance_mailer/change_password.html.erb
|
62
|
+
- generators/clearance/templates/app/views/clearance_mailer/confirmation.html.erb
|
63
|
+
- generators/clearance/templates/app/models
|
64
|
+
- generators/clearance/templates/app/models/user.rb
|
65
|
+
- generators/clearance/templates/app/models/clearance_mailer.rb
|
66
|
+
- generators/clearance/templates/app/controllers
|
67
|
+
- generators/clearance/templates/app/controllers/application.rb
|
68
|
+
- generators/clearance/templates/app/controllers/passwords_controller.rb
|
69
|
+
- generators/clearance/templates/app/controllers/users_controller.rb
|
70
|
+
- generators/clearance/templates/app/controllers/sessions_controller.rb
|
71
|
+
- generators/clearance/templates/app/controllers/confirmations_controller.rb
|
64
72
|
- generators/clearance/templates/db
|
65
73
|
- generators/clearance/templates/db/migrate
|
66
74
|
- generators/clearance/templates/db/migrate/create_users_with_clearance_columns.rb
|
67
75
|
- generators/clearance/templates/db/migrate/update_users_with_clearance_columns.rb
|
68
|
-
- generators/clearance/
|
69
|
-
- generators/clearance/
|
70
|
-
- generators/clearance/
|
71
|
-
- generators/clearance/templates/test/factories/clearance.rb
|
72
|
-
- generators/clearance/templates/test/functional
|
73
|
-
- generators/clearance/templates/test/functional/confirmations_controller_test.rb
|
74
|
-
- generators/clearance/templates/test/functional/passwords_controller_test.rb
|
75
|
-
- generators/clearance/templates/test/functional/sessions_controller_test.rb
|
76
|
-
- generators/clearance/templates/test/functional/users_controller_test.rb
|
77
|
-
- generators/clearance/templates/test/unit
|
78
|
-
- generators/clearance/templates/test/unit/clearance_mailer_test.rb
|
79
|
-
- generators/clearance/templates/test/unit/user_test.rb
|
76
|
+
- generators/clearance/lib
|
77
|
+
- generators/clearance/lib/insert_commands.rb
|
78
|
+
- generators/clearance/lib/rake_commands.rb
|
80
79
|
- generators/clearance/USAGE
|
80
|
+
- generators/clearance/clearance_generator.rb
|
81
81
|
- lib/clearance
|
82
|
-
- lib/clearance/app
|
83
|
-
- lib/clearance/app/controllers
|
84
|
-
- lib/clearance/app/controllers/application_controller.rb
|
85
|
-
- lib/clearance/app/controllers/confirmations_controller.rb
|
86
|
-
- lib/clearance/app/controllers/passwords_controller.rb
|
87
|
-
- lib/clearance/app/controllers/sessions_controller.rb
|
88
|
-
- lib/clearance/app/controllers/users_controller.rb
|
89
|
-
- lib/clearance/app/models
|
90
|
-
- lib/clearance/app/models/clearance_mailer.rb
|
91
|
-
- lib/clearance/app/models/user.rb
|
92
82
|
- lib/clearance/test
|
83
|
+
- lib/clearance/test/test_helper.rb
|
93
84
|
- lib/clearance/test/functional
|
94
85
|
- lib/clearance/test/functional/confirmations_controller_test.rb
|
95
86
|
- lib/clearance/test/functional/passwords_controller_test.rb
|
96
87
|
- lib/clearance/test/functional/sessions_controller_test.rb
|
97
88
|
- lib/clearance/test/functional/users_controller_test.rb
|
98
|
-
- lib/clearance/test/test_helper.rb
|
99
89
|
- lib/clearance/test/unit
|
100
90
|
- lib/clearance/test/unit/clearance_mailer_test.rb
|
101
91
|
- lib/clearance/test/unit/user_test.rb
|
92
|
+
- lib/clearance/app
|
93
|
+
- lib/clearance/app/models
|
94
|
+
- lib/clearance/app/models/user.rb
|
95
|
+
- lib/clearance/app/models/clearance_mailer.rb
|
96
|
+
- lib/clearance/app/controllers
|
97
|
+
- lib/clearance/app/controllers/application_controller.rb
|
98
|
+
- lib/clearance/app/controllers/passwords_controller.rb
|
99
|
+
- lib/clearance/app/controllers/users_controller.rb
|
100
|
+
- lib/clearance/app/controllers/sessions_controller.rb
|
101
|
+
- lib/clearance/app/controllers/confirmations_controller.rb
|
102
102
|
- lib/clearance.rb
|
103
103
|
- shoulda_macros/clearance.rb
|
104
104
|
- rails/init.rb
|
@@ -127,6 +127,6 @@ rubyforge_project:
|
|
127
127
|
rubygems_version: 1.2.0
|
128
128
|
signing_key:
|
129
129
|
specification_version: 2
|
130
|
-
summary:
|
130
|
+
summary: Rails authentication for developers who write tests.
|
131
131
|
test_files: []
|
132
132
|
|