Permalink
Browse files

Upgrading clearance to 0.8.2

  • Loading branch information...
1 parent cfc180b commit c5fcac91748ddd18f1fb5e8bbe284f47641d1a2a @qrush qrush committed Sep 10, 2009
Showing with 404 additions and 289 deletions.
  1. +2 −2 config/environment.rb
  2. +17 −0 db/migrate/20090910143608_clearance_update_users.rb
  3. +5 −1 db/schema.rb
  4. +1 −1 test/factories/clearance.rb
  5. +0 −2 vendor/gems/qrush-clearance-0.7.0/app/views/clearance_mailer/confirmation.html.erb
  6. +0 −143 vendor/gems/qrush-clearance-0.7.0/lib/clearance/user.rb
  7. +4 −4 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/.specification
  8. +18 −0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/CHANGELOG.textile
  9. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/LICENSE
  10. +35 −35 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/README.textile
  11. +2 −2 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/Rakefile
  12. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/TODO.textile
  13. +5 −2 ...earance-0.7.0 → thoughtbot-clearance-0.8.2}/app/controllers/clearance/confirmations_controller.rb
  14. +7 −3 ...h-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/controllers/clearance/passwords_controller.rb
  15. +2 −2 ...sh-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/controllers/clearance/sessions_controller.rb
  16. +1 −0 ...qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/controllers/clearance/users_controller.rb
  17. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/models/clearance_mailer.rb
  18. +3 −1 ...clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/clearance_mailer/change_password.html.erb
  19. +5 −0 vendor/gems/thoughtbot-clearance-0.8.2/app/views/clearance_mailer/confirmation.html.erb
  20. +1 −1 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/passwords/edit.html.erb
  21. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/passwords/new.html.erb
  22. +2 −6 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/sessions/new.html.erb
  23. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/users/_form.html.erb
  24. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/app/views/users/new.html.erb
  25. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/config/clearance_routes.rb
  26. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/USAGE
  27. 0 .../{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/clearance_generator.rb
  28. 0 .../{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/lib/insert_commands.rb
  29. 0 ...ms/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/lib/rake_commands.rb
  30. 0 ...r/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/templates/README
  31. 0 .../{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/templates/factories.rb
  32. +4 −4 ...nce-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/templates/migrations/create_users.rb
  33. +10 −10 ...nce-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/templates/migrations/update_users.rb
  34. 0 .../gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance/templates/user.rb
  35. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/USAGE
  36. +1 −1 ...0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/clearance_features_generator.rb
  37. 0 ...oughtbot-clearance-0.8.2}/generators/clearance_features/templates/features/password_reset.feature
  38. +0 −7 ....0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/templates/features/sign_in.feature
  39. +0 −8 ...0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/templates/features/sign_out.feature
  40. 0 ....0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/templates/features/sign_up.feature
  41. +14 −8 ...rance-0.8.2}/generators/clearance_features/templates/features/step_definitions/clearance_steps.rb
  42. 0 ...ce-0.8.2}/generators/clearance_features/templates/features/step_definitions/factory_girl_steps.rb
  43. 0 ...0 → thoughtbot-clearance-0.8.2}/generators/clearance_features/templates/features/support/paths.rb
  44. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance_views/USAGE
  45. 0 ...rance-0.7.0 → thoughtbot-clearance-0.8.2}/generators/clearance_views/clearance_views_generator.rb
  46. +1 −1 ...oughtbot-clearance-0.8.2}/generators/clearance_views/templates/formtastic/passwords/edit.html.erb
  47. 0 ...houghtbot-clearance-0.8.2}/generators/clearance_views/templates/formtastic/passwords/new.html.erb
  48. +0 −1 ...thoughtbot-clearance-0.8.2}/generators/clearance_views/templates/formtastic/sessions/new.html.erb
  49. 0 ...houghtbot-clearance-0.8.2}/generators/clearance_views/templates/formtastic/users/_inputs.html.erb
  50. 0 ... → thoughtbot-clearance-0.8.2}/generators/clearance_views/templates/formtastic/users/new.html.erb
  51. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/lib/clearance.rb
  52. +62 −39 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/lib/clearance/authentication.rb
  53. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/lib/clearance/extensions/errors.rb
  54. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/lib/clearance/extensions/rescue.rb
  55. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/lib/clearance/extensions/routes.rb
  56. +199 −0 vendor/gems/thoughtbot-clearance-0.8.2/lib/clearance/user.rb
  57. 0 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/rails/init.rb
  58. +3 −5 vendor/gems/{qrush-clearance-0.7.0 → thoughtbot-clearance-0.8.2}/shoulda_macros/clearance.rb
View
@@ -7,10 +7,10 @@
config.gem 'haml',
:version => '2.1.0'
- config.gem "qrush-clearance",
+ config.gem "thoughtbot-clearance",
:lib => 'clearance',
:source => 'http://gems.github.com',
- :version => '0.7.0'
+ :version => '0.8.2'
config.gem "ddollar-pacecar",
:lib => 'pacecar',
:source => 'http://gems.github.com',
@@ -0,0 +1,17 @@
+class ClearanceUpdateUsers < ActiveRecord::Migration
+ def self.up
+ change_table(:users) do |t|
+ t.string :confirmation_token, :limit => 128
+ t.string :remember_token, :limit => 128
+ end
+
+ add_index :users, [:id, :confirmation_token]
+ add_index :users, :remember_token
+ end
+
+ def self.down
+ change_table(:users) do |t|
+ t.remove :confirmation_token,:remember_token
+ end
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090901141418) do
+ActiveRecord::Schema.define(:version => 20090910143608) do
create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
@@ -91,10 +91,14 @@
t.datetime "token_expires_at"
t.boolean "email_confirmed", :default => false, :null => false
t.string "api_key"
+ t.string "confirmation_token", :limit => 128
+ t.string "remember_token", :limit => 128
end
add_index "users", ["email"], :name => "index_users_on_email"
+ add_index "users", ["id", "confirmation_token"], :name => "index_users_on_id_and_confirmation_token"
add_index "users", ["id", "token"], :name => "index_users_on_id_and_token"
+ add_index "users", ["remember_token"], :name => "index_users_on_remember_token"
add_index "users", ["token"], :name => "index_users_on_token"
create_table "versions", :force => true do |t|
@@ -1,5 +1,5 @@
Factory.sequence :email do |n|
- "user#{Time.now.to_i + n}@example.com"
+ "user#{n}@example.com"
end
Factory.define :user do |user|
@@ -1,2 +0,0 @@
-
-<%= new_user_confirmation_url :user_id => @user, :token => @user.token, :encode => false %>
@@ -1,143 +0,0 @@
-require 'digest/sha1'
-
-module Clearance
- module User
-
- def self.included(model)
- model.extend(ClassMethods)
-
- model.send(:include, InstanceMethods)
- model.send(:include, AttrAccessible)
- model.send(:include, AttrAccessor)
- model.send(:include, Validations)
- model.send(:include, Callbacks)
- end
-
- module AttrAccessible
- def self.included(model)
- model.class_eval do
- attr_accessible :email, :password, :password_confirmation
- end
- end
- end
-
- module AttrAccessor
- def self.included(model)
- model.class_eval do
- attr_accessor :password, :password_confirmation
- end
- end
- end
-
- module Validations
- def self.included(model)
- model.class_eval do
- validates_presence_of :email
- validates_uniqueness_of :email, :case_sensitive => false
- validates_format_of :email, :with => %r{.+@.+\..+}
-
- validates_presence_of :password, :if => :password_required?
- validates_confirmation_of :password, :if => :password_required?
- end
- end
- end
-
- module Callbacks
- def self.included(model)
- model.class_eval do
- before_save :initialize_salt, :encrypt_password, :initialize_token
- end
- end
- end
-
- module InstanceMethods
- def authenticated?(password)
- encrypted_password == encrypt(password)
- end
-
- def encrypt(string)
- generate_hash("--#{salt}--#{string}--")
- end
-
- def remember?
- token_expires_at && Time.now.utc < token_expires_at
- end
-
- def remember_me!
- remember_me_until! 2.weeks.from_now.utc
- end
-
- def forget_me!
- clear_token
- save(false)
- end
-
- def confirm_email!
- self.email_confirmed = true
- self.token = nil
- save(false)
- end
-
- def forgot_password!
- generate_token
- save(false)
- end
-
- def update_password(new_password, new_password_confirmation)
- self.password = new_password
- self.password_confirmation = new_password_confirmation
- clear_token if valid?
- save
- end
-
- protected
-
- def generate_hash(string)
- Digest::SHA1.hexdigest(string)
- end
-
- def initialize_salt
- if new_record?
- self.salt = generate_hash("--#{Time.now.utc.to_s}--#{password}--")
- end
- end
-
- def encrypt_password
- return if password.blank?
- self.encrypted_password = encrypt(password)
- end
-
- def generate_token
- self.token = encrypt("--#{Time.now.utc.to_s}--#{password}--")
- self.token_expires_at = nil
- end
-
- def clear_token
- self.token = nil
- self.token_expires_at = nil
- end
-
- def initialize_token
- generate_token if new_record?
- end
-
- def password_required?
- encrypted_password.blank? || !password.blank?
- end
-
- def remember_me_until!(time)
- self.token_expires_at = time
- self.token = encrypt("--#{token_expires_at}--#{password}--")
- save(false)
- end
- end
-
- module ClassMethods
- def authenticate(email, password)
- return nil unless user = find_by_email(email)
- return user if user.authenticated?(password)
- end
- end
-
- end
-end
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
-name: qrush-clearance
+name: thoughtbot-clearance
version: !ruby/object:Gem::Version
- version: 0.7.0
+ version: 0.8.2
platform: ruby
authors:
- Dan Croak
@@ -24,7 +24,7 @@ autorequire:
bindir: bin
cert_chain: []
-date: 2009-08-04 00:00:00 -04:00
+date: 2009-09-01 00:00:00 -04:00
default_executable:
dependencies: []
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
requirements: []
rubyforge_project:
-rubygems_version: 1.3.4
+rubygems_version: 1.3.5
signing_key:
specification_version: 3
summary: Rails authentication with email & password.
@@ -1,3 +1,20 @@
+h2. 0.8.2 (09/01/2009)
+
+* current_user= accessor method. (Joe Ferris, Josh Clayton)
+* set current_user in sign_in. (Jon Yurek)
+
+h2. 0.8.1 (08/31/2009)
+
+* Removed unnecessary remember_token_expires_at column and the
+remember? and forget_me! user instance methods. (Dan Croak)
+
+h2. 0.8.0 (08/31/2009)
+
+* Always remember me. Replaced session-and-remember-me authentication with
+always using a cookie with a long timeout. (Dan Croak)
+* Documented Clearance::Authentication with YARD. (Dan Croak)
+* Documented Clearance::User with YARD. (Dan Croak)
+
h2. 0.7.0 (08/04/2009)
* Redirect signed in user who clicks confirmation link again. (Dan Croak)
@@ -57,6 +74,7 @@ h2. 0.6.2 (04/22/2009)
* World(NavigationHelpers) Cucumber 3.0 style. (Shay Arnett & Mark Cornick)
h2. 0.6.1 (04/21/2009)
+
* Scope operators are necessary to keep Rails happy. Reverting the original
revert so they're back in the library now for constants referenced inside of
the gem. (Nick Quaranto)
@@ -4,9 +4,9 @@ Rails authentication with email & password.
"We have clearance, Clarence.":http://www.youtube.com/v/mNRXJEE3Nz8
-h2. Wiki
+h2. Suspenders
-Most information regarding Clearance is on the "Github Wiki":http://wiki.github.com/thoughtbot/clearance.
+Clearance is included in "Suspenders":http://github.com/thoughtbot/suspenders, which thoughtbot uses on all of our apps. We highly recommend you try it. Suspenders is the "King Gem" in our ecosystem, representating what we think the current state-of-the-art is in Rails development.
h2. Installation
@@ -15,10 +15,10 @@ Clearance is a Rails engine. It works with versions of Rails greater than 2.3.
In config/environment.rb:
<pre>
-config.gem "thoughtbot-clearance",
- :lib => 'clearance',
- :source => 'http://gems.github.com',
- :version => '0.7.0'
+config.gem "thoughtbot-clearance",
+ :lib => 'clearance',
+ :source => 'http://gems.github.com',
+ :version => '0.8.2'
</pre>
Vendor the gem:
@@ -30,59 +30,47 @@ rake gems:unpack
Make sure the development database exists and run the generator:
-@script/generate clearance@
+<pre>
+script/generate clearance
+</pre>
A number of files will be created and instructions will be printed.
You may already have some of these files. Don't worry. You'll be asked if you want to overwrite them.
Run the migration:
-@rake db:migrate@
+<pre>
+rake db:migrate
+</pre>
+
+h2. If you aren't on Suspenders, you aren't done
Define a HOST constant in your environment files.
In config/environments/test.rb and config/environments/development.rb it can be:
-@HOST = "localhost"@
+<pre>
+HOST = "localhost"
+</pre>
In production.rb it must be the actual host your application is deployed to.
The constant is used by mailers to generate URLs in emails.
In config/environment.rb:
-@DO_NOT_REPLY = "donotreply@example.com"@
-
-Define root_url to *something* in your config/routes.rb:
-
-@map.root :controller => 'home'@
-
-h2. Cucumber Features
-
-As your app evolves, you want to know that authentication still works. Clearance's opinion is that you should test its integration with your app using "Cucumber":http://cukes.info/.
-
-In config/environments/test.rb:
-
<pre>
-config.gem 'webrat',
- :version => '>= 0.4.4'
-config.gem 'cucumber',
- :version => '>= 0.3.0'
-config.gem 'thoughtbot-factory_girl',
- :lib => 'factory_girl',
- :source => "http://gems.github.com",
- :version => '1.2.1'
+DO_NOT_REPLY = "donotreply@example.com"
</pre>
-Vendor the gems:
+Define root_url to *something* in your config/routes.rb:
<pre>
-rake gems:install RAILS_ENV=test
-rake gems:unpack RAILS_ENV=test
+map.root :controller => 'home'
</pre>
-We don't vendor nokogiri due to its native extensions, so install it normally on your machine:
+h2. Cucumber Features
-@sudo gem install nokogiri@
+As your app evolves, you want to know that authentication still works. thoughtbot's opinion is that you should test its integration with your app using "Cucumber":http://cukes.info/.
Run the Cucumber generator (if you haven't already) and Clearance's feature generator:
@@ -107,11 +95,23 @@ def path_to(page_name)
end
</pre>
+h2. Formtastic views
+
+We have begun standardizing our forms using "Formtastic":http://github.com/justinfrench/formtastic. We highly recommend trying it. It will make your Rails view life more interesting.
+
+Clearance has another generator to generate Formastic views:
+
+<pre>
+script/generate clearance_views
+</pre>
+
+Its implementation is designed so that other view styles can be generated if the community wants it. However, we haven't needed them so you'll have to write the patch and send it back if you want other styles (such as Haml).
+
h2. Authors
Clearance was extracted out of "Hoptoad":http://hoptoadapp.com. We merged the authentication code from two of thoughtbot's clients' Rails apps and have since used it each time we need authentication. The following people have improved the library. Thank you!
-Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov, Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey, Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton & Mustafa Ekim.
+Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov, Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey, Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton, Mustafa Ekim, & Jon Yurek.
h2. Questions?
Oops, something went wrong.

0 comments on commit c5fcac9

Please sign in to comment.