clearance 0.8.8 → 0.9.0.rc1

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.

Files changed (94) hide show
  1. data/CHANGELOG.md +8 -0
  2. data/README.md +27 -32
  3. data/Rakefile +25 -31
  4. data/app/controllers/clearance/passwords_controller.rb +1 -1
  5. data/app/controllers/clearance/sessions_controller.rb +1 -1
  6. data/app/models/clearance_mailer.rb +4 -4
  7. data/app/views/passwords/edit.html.erb +1 -1
  8. data/app/views/passwords/new.html.erb +2 -2
  9. data/app/views/sessions/new.html.erb +1 -1
  10. data/app/views/users/_form.html.erb +1 -1
  11. data/app/views/users/new.html.erb +1 -1
  12. data/config/routes.rb +30 -0
  13. data/lib/clearance.rb +2 -1
  14. data/lib/clearance/authentication.rb +2 -2
  15. data/lib/clearance/configuration.rb +10 -3
  16. data/lib/clearance/engine.rb +8 -0
  17. data/lib/clearance/user.rb +5 -6
  18. data/lib/rails/generators/clearance_features_generator.rb +20 -0
  19. data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/password_reset.feature +1 -1
  20. data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_in.feature +0 -0
  21. data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_out.feature +0 -0
  22. data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/sign_up.feature +0 -0
  23. data/{generators/clearance_features/templates → lib/rails/generators/clearance_features_templates}/features/step_definitions/clearance_steps.rb +13 -5
  24. data/lib/rails/generators/clearance_generator.rb +68 -0
  25. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/README +0 -0
  26. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/clearance.rb +0 -0
  27. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/factories.rb +0 -0
  28. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/migrations/create_users.rb +0 -1
  29. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/migrations/update_users.rb +0 -1
  30. data/{generators/clearance/templates → lib/rails/generators/clearance_templates}/user.rb +0 -0
  31. data/lib/rails/generators/clearance_views_generator.rb +14 -0
  32. data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/passwords/edit.html.erb +3 -3
  33. data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/passwords/new.html.erb +3 -3
  34. data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/sessions/new.html.erb +3 -3
  35. data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/users/_inputs.html.erb +1 -1
  36. data/{generators/clearance_views/templates/formtastic → lib/rails/generators/clearance_views_templates/formtastic/erb}/users/new.html.erb +2 -2
  37. data/shoulda_macros/clearance.rb +9 -17
  38. data/test/controllers/confirmations_controller_test.rb +6 -6
  39. data/test/controllers/passwords_controller_test.rb +10 -10
  40. data/test/controllers/sessions_controller_test.rb +57 -16
  41. data/test/controllers/users_controller_test.rb +12 -8
  42. data/test/models/clearance_mailer_test.rb +2 -2
  43. data/test/models/user_test.rb +14 -7
  44. data/test/rails_root/app/helpers/application_helper.rb +0 -3
  45. data/test/rails_root/config/application.rb +46 -0
  46. data/test/rails_root/config/boot.rb +5 -109
  47. data/test/rails_root/config/environment.rb +5 -15
  48. data/test/rails_root/config/environments/development.rb +15 -15
  49. data/test/rails_root/config/environments/production.rb +42 -1
  50. data/test/rails_root/config/environments/test.rb +25 -29
  51. data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
  52. data/test/rails_root/config/initializers/inflections.rb +1 -1
  53. data/test/rails_root/config/initializers/secret_token.rb +7 -0
  54. data/test/rails_root/config/initializers/session_store.rb +8 -0
  55. data/test/rails_root/config/routes.rb +57 -2
  56. data/test/rails_root/features/step_definitions/web_steps.rb +125 -165
  57. data/test/rails_root/features/support/env.rb +24 -14
  58. data/test/rails_root/features/support/paths.rb +26 -4
  59. data/test/rails_root/test/functional/accounts_controller_test.rb +0 -1
  60. data/test/rails_root/test/performance/browsing_test.rb +9 -0
  61. data/test/rails_root/test/test_helper.rb +13 -0
  62. data/test/rails_root/vendor/plugins/dynamic_form/init.rb +5 -0
  63. data/test/rails_root/vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb +300 -0
  64. data/test/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
  65. data/test/rails_root/vendor/plugins/dynamic_form/test/dynamic_form_test.rb +370 -0
  66. data/test/rails_root/vendor/plugins/dynamic_form/test/test_helper.rb +9 -0
  67. data/test/test_helper.rb +30 -1
  68. metadata +104 -49
  69. data/VERSION +0 -1
  70. data/generators/clearance/USAGE +0 -1
  71. data/generators/clearance/clearance_generator.rb +0 -68
  72. data/generators/clearance/lib/insert_commands.rb +0 -33
  73. data/generators/clearance/lib/rake_commands.rb +0 -22
  74. data/generators/clearance_features/USAGE +0 -1
  75. data/generators/clearance_features/clearance_features_generator.rb +0 -19
  76. data/generators/clearance_features/templates/features/support/paths.rb +0 -23
  77. data/generators/clearance_views/USAGE +0 -0
  78. data/generators/clearance_views/clearance_views_generator.rb +0 -27
  79. data/lib/clearance/routes.rb +0 -49
  80. data/test/rails_root/app/helpers/confirmations_helper.rb +0 -2
  81. data/test/rails_root/app/helpers/passwords_helper.rb +0 -2
  82. data/test/rails_root/config/initializers/requires.rb +0 -13
  83. data/test/rails_root/config/initializers/time_formats.rb +0 -4
  84. data/test/rails_root/db/migrate/20100225210436_clearance_create_users.rb +0 -21
  85. data/test/rails_root/features/step_definitions/clearance_steps.rb +0 -122
  86. data/test/rails_root/features/step_definitions/factory_girl_steps.rb +0 -5
  87. data/test/rails_root/public/dispatch.rb +0 -10
  88. data/test/rails_root/script/create_project.rb +0 -52
  89. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/generators/formtastic_stylesheets/formtastic_stylesheets_generator.rb +0 -21
  90. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/formtastic.rb +0 -1236
  91. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/lib/justin_french/formtastic.rb +0 -10
  92. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/rails/init.rb +0 -3
  93. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/formtastic_spec.rb +0 -2900
  94. data/test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1/spec/test_helper.rb +0 -14
@@ -1,5 +1,13 @@
1
+ 0.8.9 (unreleased)
2
+ ------------------
3
+
4
+ * Removed unnecessary db index. (Rich Thornett, doctorzaius)
5
+ * [#79] Allow customization of cookie duration. (Ron Newman, Dan Croak)
6
+ * [#77] rake generator:cleanup needed to be... cleaned up. (Ron Newman)
7
+
1
8
  0.8.8 (02/25/2010)
2
9
  ------------------
10
+
3
11
  * Fixed sign_in and sign_out not setting current_user (Joe Ferris)
4
12
 
5
13
  0.8.7 (02/21/2010)
data/README.md CHANGED
@@ -3,7 +3,7 @@ Clearance
3
3
 
4
4
  Rails authentication with email & password.
5
5
 
6
- [We have clearance, Clarence.](http://www.youtube.com/v/mNRXJEE3Nz8)
6
+ [We have clearance, Clarence.](http://www.youtube.com/watch?v=fVq4_HhBK8Y)
7
7
 
8
8
  Help
9
9
  ----
@@ -20,23 +20,23 @@ Fork away and create a [Github Issue](http://github.com/thoughtbot/clearance/iss
20
20
  Installation
21
21
  ------------
22
22
 
23
- Clearance is a Rails engine. It works with versions of Rails greater than 2.3.
23
+ Clearance is a Rails engine. The latest stable version works with versions of Rails greater than 3. If you need to run on Rails 2.x, install Clearance Version 0.8.8.
24
24
 
25
- Install it as a gem however you like to install gems. Gem Bundler example:
25
+ Install it as a gem however you like to install gems. Also, uninstall old versions:
26
26
 
27
- gem "clearance"
27
+ sudo gem uninstall thoughtbot-clearance
28
+ sudo gem uninstall clearance
29
+ sudo gem install clearance
28
30
 
29
- Make sure the development database exists and run the generator:
31
+ Make sure the development database exists, then run the generator:
30
32
 
31
- script/generate clearance
33
+ script/rails generate clearance
32
34
 
33
35
  This:
34
36
 
35
37
  * inserts Clearance::User into your User model
36
38
  * inserts Clearance::Authentication into your ApplicationController
37
- * inserts Clearance::Routes.draw(map) into your config.routes.rb
38
39
  * created a migration that either creates a users table or adds only missing columns
39
- * prints further instructions
40
40
 
41
41
  Usage
42
42
  -----
@@ -65,11 +65,11 @@ To change any of provided actions, subclass a Clearance controller...
65
65
  end
66
66
  end
67
67
 
68
- and add your route above (before) Clearance routes in config/routes.rb:
68
+ and add your route in config/routes.rb:
69
69
 
70
- map.resource :session, :controller => 'sessions'
70
+ resource :session, :controller => 'sessions'
71
71
 
72
- See lib/clearance/routes.rb for all the routes Clearance provides.
72
+ See config/routes.rb for all the routes Clearance provides.
73
73
 
74
74
  Actions that redirect (create, update, and destroy) in Clearance controllers
75
75
  can be overriden by re-defining url_after_(action) methods as seen above.
@@ -83,33 +83,27 @@ opinion is that you should test its integration with your app using
83
83
 
84
84
  Run the Cucumber generator and Clearance feature generator:
85
85
 
86
- script/generate cucumber
87
- script/generate clearance_features
88
-
89
- All of the files generated should be new with the exception of the
90
- features/support/paths.rb file. If you have not modified your paths.rb then you
91
- will be okay to replace it with this one. If you need to keep your paths.rb
92
- file then add these locations in your paths.rb manually:
93
-
94
- def path_to(page_name)
95
- case page_name
96
- when /the sign up page/i
97
- new_user_path
98
- when /the sign in page/i
99
- new_session_path
100
- when /the password reset request page/i
101
- new_password_path
102
- end
103
- end
86
+ script/rails generate cucumber
87
+ script/rails generate clearance_features
88
+
89
+ Edit your Gemfile to include:
90
+
91
+ gem 'factory_girl'
92
+
93
+ Edit your config/enviroments/cucumber.rb to include the following:
94
+
95
+ ActionMailer::Base.default_url_options = { :host => 'localhost:3000' }
96
+
97
+ Then run rake!
104
98
 
105
99
  Optional Formtastic views
106
100
  -------------------------
107
101
 
108
- We use & recommend [Formtastic](http://github.com/justinfrench/formtastic].
102
+ We use & recommend [Formtastic](http://github.com/justinfrench/formtastic).
109
103
 
110
104
  Clearance has another generator to generate Formastic views:
111
105
 
112
- script/generate clearance_views
106
+ script/rails generate clearance_views
113
107
 
114
108
  Its implementation is designed so other view styles (Haml?) can be generated.
115
109
 
@@ -126,4 +120,5 @@ Dan Croak, Mike Burns, Jason Morrison, Joe Ferris, Eugene Bolshakov,
126
120
  Nick Quaranto, Josh Nichols, Mike Breen, Marcel Görner, Bence Nagy, Ben Mabey,
127
121
  Eloy Duran, Tim Pope, Mihai Anca, Mark Cornick, Shay Arnett, Joshua Clayton,
128
122
  Mustafa Ekim, Jon Yurek, Anuj Dutta, Chad Pytel, Ben Orenstein, Bobby Wilson,
129
- Matthew Ford, Ryan McGeary, Claudio Poli, Joseph Holsten, and Peter Haza.
123
+ Matthew Ford, Ryan McGeary, Claudio Poli, Joseph Holsten, Peter Haza,
124
+ Ron Newman, and Rich Thornett.
data/Rakefile CHANGED
@@ -1,39 +1,46 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ENV['BUNDLE_GEMFILE'] = File.dirname(__FILE__) + '/test/rails_root/Gemfile'
4
+
3
5
  require 'rake'
4
6
  require 'rake/testtask'
5
7
  require 'cucumber/rake/task'
6
8
 
7
9
  namespace :test do
8
10
  Rake::TestTask.new(:basic => ["generator:cleanup",
9
- "generator:clearance",
10
- "generator:clearance_features"]) do |task|
11
+ "generator:clearance"]) do |task|
11
12
  task.libs << "lib"
12
13
  task.libs << "test"
13
- task.pattern = "test/**/*_test.rb"
14
+ task.pattern = "test/*/*_test.rb"
14
15
  task.verbose = false
15
16
  end
16
17
 
17
- Rake::TestTask.new(:views => ["generator:clearance_views"]) do |task|
18
+ Rake::TestTask.new(:views => ["generator:cleanup",
19
+ "generator:clearance",
20
+ "generator:clearance_views"]) do |task|
18
21
  task.libs << "lib"
19
22
  task.libs << "test"
20
- task.pattern = "test/**/*_test.rb"
23
+ task.pattern = "test/*/*_test.rb"
21
24
  task.verbose = false
22
25
  end
23
26
 
24
- Cucumber::Rake::Task.new(:features) do |t|
27
+
28
+ Cucumber::Rake::Task.new(:features => ["generator:cleanup",
29
+ "generator:clearance",
30
+ "generator:clearance_features"]) do |t|
25
31
  t.cucumber_opts = "--format progress"
26
32
  t.profile = 'features'
27
33
  end
28
34
 
29
- Cucumber::Rake::Task.new(:features_for_views) do |t|
35
+ Cucumber::Rake::Task.new(:features_for_views => ["generator:cleanup",
36
+ "generator:clearance",
37
+ "generator:clearance_features",
38
+ "generator:clearance_views"]) do |t|
30
39
  t.cucumber_opts = "--format progress"
31
40
  t.profile = 'features_for_views'
32
41
  end
33
42
  end
34
43
 
35
- generators = %w(clearance clearance_features clearance_views)
36
-
37
44
  namespace :generator do
38
45
  desc "Cleans up the test app before running the generator"
39
46
  task :cleanup do
@@ -42,46 +49,33 @@ namespace :generator do
42
49
  end
43
50
 
44
51
  FileUtils.rm_rf("test/rails_root/vendor/plugins/clearance")
52
+ FileUtils.rm_rf("test/rails_root/app/views/passwords")
53
+ FileUtils.rm_rf("test/rails_root/app/views/sessions")
54
+ FileUtils.rm_rf("test/rails_root/app/views/users")
45
55
  FileUtils.mkdir_p("test/rails_root/vendor/plugins")
46
56
  clearance_root = File.expand_path(File.dirname(__FILE__))
47
57
  system("ln -s #{clearance_root} test/rails_root/vendor/plugins/clearance")
58
+ FileList["test/rails_root/features/*.feature"].each do |each|
59
+ FileUtils.rm_rf(each)
60
+ end
48
61
  end
49
62
 
50
63
  desc "Run the clearance generator"
51
64
  task :clearance do
52
- system "cd test/rails_root && ./script/generate clearance -f && rake db:migrate db:test:prepare"
65
+ system "cd test/rails_root && bundle install && ./script/rails generate clearance && rake db:migrate db:test:prepare"
53
66
  end
54
67
 
55
68
  desc "Run the clearance features generator"
56
69
  task :clearance_features do
57
- system "cd test/rails_root && ./script/generate clearance_features -f"
70
+ system "cd test/rails_root && ./script/rails generate clearance_features"
58
71
  end
59
72
 
60
73
  desc "Run the clearance views generator"
61
74
  task :clearance_views do
62
- system "cd test/rails_root && ./script/generate clearance_views -f"
75
+ system "cd test/rails_root && ./script/rails generate clearance_views"
63
76
  end
64
77
  end
65
78
 
66
79
  desc "Run the test suite"
67
80
  task :default => ['test:basic', 'test:features',
68
81
  'test:views', 'test:features_for_views']
69
-
70
- require 'jeweler'
71
-
72
- Jeweler::Tasks.new do |gem|
73
- gem.name = "clearance"
74
- gem.summary = "Rails authentication with email & password."
75
- gem.description = "Rails authentication with email & password."
76
- gem.email = "support@thoughtbot.com"
77
- gem.homepage = "http://github.com/thoughtbot/clearance"
78
- gem.authors = ["Dan Croak", "Mike Burns", "Jason Morrison",
79
- "Joe Ferris", "Eugene Bolshakov", "Nick Quaranto",
80
- "Josh Nichols", "Mike Breen", "Marcel Görner",
81
- "Bence Nagy", "Ben Mabey", "Eloy Duran",
82
- "Tim Pope", "Mihai Anca", "Mark Cornick",
83
- "Shay Arnett", "Jon Yurek", "Chad Pytel"]
84
- gem.files = FileList["[A-Z]*", "{app,config,generators,lib,shoulda_macros,rails}/**/*"]
85
- end
86
-
87
- Jeweler::GemcutterTasks.new
@@ -13,7 +13,7 @@ class Clearance::PasswordsController < ApplicationController
13
13
  def create
14
14
  if user = ::User.find_by_email(params[:password][:email])
15
15
  user.forgot_password!
16
- ::ClearanceMailer.deliver_change_password user
16
+ ::ClearanceMailer.change_password(user).deliver
17
17
  flash_notice_after_create
18
18
  redirect_to(url_after_create)
19
19
  else
@@ -21,7 +21,7 @@ class Clearance::SessionsController < ApplicationController
21
21
  flash_success_after_create
22
22
  redirect_back_or(url_after_create)
23
23
  else
24
- ::ClearanceMailer.deliver_confirmation(@user)
24
+ ::ClearanceMailer.confirmation(@user).deliver
25
25
  flash_notice_after_create
26
26
  redirect_to(sign_in_url)
27
27
  end
@@ -1,21 +1,21 @@
1
1
  class ClearanceMailer < ActionMailer::Base
2
2
 
3
3
  def change_password(user)
4
+ @user = user
4
5
  from Clearance.configuration.mailer_sender
5
- recipients user.email
6
+ recipients @user.email
6
7
  subject I18n.t(:change_password,
7
8
  :scope => [:clearance, :models, :clearance_mailer],
8
9
  :default => "Change your password")
9
- body :user => user
10
10
  end
11
11
 
12
12
  def confirmation(user)
13
+ @user = user
13
14
  from Clearance.configuration.mailer_sender
14
- recipients user.email
15
+ recipients @user.email
15
16
  subject I18n.t(:confirmation,
16
17
  :scope => [:clearance, :models, :clearance_mailer],
17
18
  :default => "Account confirmation")
18
- body :user => user
19
19
  end
20
20
 
21
21
  end
@@ -6,7 +6,7 @@
6
6
 
7
7
  <%= error_messages_for :user %>
8
8
 
9
- <% form_for(:user,
9
+ <%= form_for(:user,
10
10
  :url => user_password_path(@user, :token => @user.confirmation_token),
11
11
  :html => { :method => :put }) do |form| %>
12
12
  <div class="password_field">
@@ -4,7 +4,7 @@
4
4
  We will email you a link to change your password.
5
5
  </p>
6
6
 
7
- <% form_for :password, :url => passwords_path do |form| %>
7
+ <%= form_for :password, :url => passwords_path do |form| %>
8
8
  <div class="text_field">
9
9
  <%= form.label :email, "Email address" %>
10
10
  <%= form.text_field :email %>
@@ -12,4 +12,4 @@
12
12
  <div class="submit_field">
13
13
  <%= form.submit "Reset password", :disable_with => "Please wait..." %>
14
14
  </div>
15
- <% end %>
15
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <h2>Sign in</h2>
2
2
 
3
- <% form_for :session, :url => session_path do |form| %>
3
+ <%= form_for :session, :url => session_path do |form| %>
4
4
  <div class="text_field">
5
5
  <%= form.label :email %>
6
6
  <%= form.text_field :email %>
@@ -10,4 +10,4 @@
10
10
  <div class="password_field">
11
11
  <%= form.label :password_confirmation, "Confirm password" %>
12
12
  <%= form.password_field :password_confirmation %>
13
- </div>
13
+ </div>
@@ -1,6 +1,6 @@
1
1
  <h2>Sign up</h2>
2
2
 
3
- <% form_for @user do |form| %>
3
+ <%= form_for @user do |form| %>
4
4
  <%= render :partial => '/users/form', :object => form %>
5
5
  <%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
6
6
  <% end %>
@@ -0,0 +1,30 @@
1
+ Rails.application.routes.draw do |map|
2
+ map.resources :passwords,
3
+ :controller => 'clearance/passwords',
4
+ :only => [:new, :create]
5
+
6
+ map.resource :session,
7
+ :controller => 'clearance/sessions',
8
+ :only => [:new, :create, :destroy]
9
+
10
+ map.resources :users, :controller => 'clearance/users' do |users|
11
+ users.resource :password,
12
+ :controller => 'clearance/passwords',
13
+ :only => [:create, :edit, :update]
14
+
15
+ users.resource :confirmation,
16
+ :controller => 'clearance/confirmations',
17
+ :only => [:new, :create]
18
+ end
19
+
20
+ map.sign_up 'sign_up',
21
+ :controller => 'clearance/users',
22
+ :action => 'new'
23
+ map.sign_in 'sign_in',
24
+ :controller => 'clearance/sessions',
25
+ :action => 'new'
26
+ map.sign_out 'sign_out',
27
+ :controller => 'clearance/sessions',
28
+ :action => 'destroy',
29
+ :method => :delete
30
+ end
@@ -2,6 +2,7 @@ require 'clearance/extensions/errors'
2
2
  require 'clearance/extensions/rescue'
3
3
 
4
4
  require 'clearance/configuration'
5
- require 'clearance/routes'
6
5
  require 'clearance/authentication'
7
6
  require 'clearance/user'
7
+
8
+ require 'clearance/engine'
@@ -64,7 +64,7 @@ module Clearance
64
64
  if user
65
65
  cookies[:remember_token] = {
66
66
  :value => user.remember_token,
67
- :expires => 1.year.from_now.utc
67
+ :expires => Clearance.configuration.cookie_expiration.call
68
68
  }
69
69
  self.current_user = user
70
70
  end
@@ -105,7 +105,7 @@ module Clearance
105
105
 
106
106
  def store_location
107
107
  if request.get?
108
- session[:return_to] = request.request_uri
108
+ session[:return_to] = request.fullpath
109
109
  end
110
110
  end
111
111
 
@@ -1,9 +1,10 @@
1
1
  module Clearance
2
2
  class Configuration
3
- attr_accessor :mailer_sender
3
+ attr_accessor :mailer_sender, :cookie_expiration
4
4
 
5
5
  def initialize
6
- @mailer_sender = 'donotreply@example.com'
6
+ @mailer_sender = 'donotreply@example.com'
7
+ @cookie_expiration = lambda { 1.year.from_now.utc }
7
8
  end
8
9
  end
9
10
 
@@ -14,9 +15,15 @@ module Clearance
14
15
  # Configure Clearance someplace sensible,
15
16
  # like config/initializers/clearance.rb
16
17
  #
18
+ # If you want users to only be signed in during the current session
19
+ # instead of being remembered, do this:
20
+ #
21
+ # config.cookie_expiration = lambda { }
22
+ #
17
23
  # @example
18
24
  # Clearance.configure do |config|
19
- # config.mailer_sender = 'donotreply@example.com'
25
+ # config.mailer_sender = 'me@example.com'
26
+ # config.cookie_expiration = lambda { 2.weeks.from_now.utc }
20
27
  # end
21
28
  def self.configure
22
29
  self.configuration ||= Configuration.new
@@ -0,0 +1,8 @@
1
+ require "clearance"
2
+ require "rails"
3
+
4
+ module Clearance
5
+ class Engine < Rails::Engine
6
+ engine_name :clearance
7
+ end
8
+ end
@@ -16,7 +16,6 @@ module Clearance
16
16
  #
17
17
  # @see ClassMethods
18
18
  # @see InstanceMethods
19
- # @see AttrAccessible
20
19
  # @see AttrAccessor
21
20
  # @see Validations
22
21
  # @see Callbacks
@@ -54,7 +53,7 @@ module Clearance
54
53
  validates_format_of :email, :with => %r{.+@.+\..+}, :allow_blank => true
55
54
 
56
55
  validates_presence_of :password, :unless => :password_optional?
57
- validates_confirmation_of :password, :unless => :password_optional?
56
+ validates_confirmation_of :password
58
57
  end
59
58
  end
60
59
  end
@@ -99,7 +98,7 @@ module Clearance
99
98
  # user.reset_remember_token!
100
99
  def reset_remember_token!
101
100
  generate_remember_token
102
- save(false)
101
+ save(:validate => false)
103
102
  end
104
103
 
105
104
  # Confirm my email.
@@ -109,7 +108,7 @@ module Clearance
109
108
  def confirm_email!
110
109
  self.email_confirmed = true
111
110
  self.confirmation_token = nil
112
- save(false)
111
+ save(:validate => false)
113
112
  end
114
113
 
115
114
  # Mark my account as forgotten password.
@@ -118,7 +117,7 @@ module Clearance
118
117
  # user.forgot_password!
119
118
  def forgot_password!
120
119
  generate_confirmation_token
121
- save(false)
120
+ save(:validate => false)
122
121
  end
123
122
 
124
123
  # Update my password.
@@ -186,7 +185,7 @@ module Clearance
186
185
  end
187
186
 
188
187
  def send_confirmation_email
189
- ClearanceMailer.deliver_confirmation self
188
+ ClearanceMailer.confirmation(self).deliver
190
189
  end
191
190
  end
192
191