sorcery 0.5.0 → 0.5.2

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.
Files changed (54) hide show
  1. data/README.rdoc +1 -1
  2. data/VERSION +1 -1
  3. data/lib/sorcery/controller/adapters/sinatra.rb +35 -28
  4. data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
  5. data/lib/sorcery/engine.rb +0 -7
  6. data/lib/sorcery/initializers/initializer.rb +4 -2
  7. data/lib/sorcery/model/adapters/mongoid.rb +10 -5
  8. data/lib/sorcery/model/submodules/reset_password.rb +5 -3
  9. data/lib/sorcery/model.rb +4 -5
  10. data/lib/sorcery/test_helpers/internal/rails.rb +1 -0
  11. data/lib/sorcery/test_helpers/internal/sinatra.rb +3 -3
  12. data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +74 -0
  13. data/lib/sorcery.rb +3 -5
  14. data/sorcery.gemspec +54 -2
  15. data/spec/Gemfile.lock +1 -4
  16. data/spec/rails3/Gemfile.lock +1 -4
  17. data/spec/rails3/spec/user_reset_password_spec.rb +1 -1
  18. data/spec/rails3/spec/user_spec.rb +0 -10
  19. data/spec/rails3_mongoid/Gemfile.lock +1 -4
  20. data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +12 -4
  21. data/spec/rails3_mongoid/spec/user_spec.rb +0 -10
  22. data/spec/sinatra/Gemfile +3 -0
  23. data/spec/sinatra/Gemfile.lock +17 -34
  24. data/spec/sinatra/Rakefile +1 -1
  25. data/spec/sinatra/filters.rb +20 -14
  26. data/spec/sinatra/modular.rb +157 -0
  27. data/spec/sinatra_modular/Gemfile +15 -0
  28. data/spec/sinatra_modular/Gemfile.lock +117 -0
  29. data/spec/sinatra_modular/Rakefile +11 -0
  30. data/spec/sinatra_modular/authentication.rb +3 -0
  31. data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +17 -0
  32. data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +17 -0
  33. data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +11 -0
  34. data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +16 -0
  35. data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +14 -0
  36. data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +15 -0
  37. data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +13 -0
  38. data/spec/sinatra_modular/filters.rb +27 -0
  39. data/spec/sinatra_modular/modular.rb +157 -0
  40. data/spec/sinatra_modular/myapp.rb +133 -0
  41. data/spec/sinatra_modular/sorcery_mailer.rb +25 -0
  42. data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +85 -0
  43. data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +70 -0
  44. data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +53 -0
  45. data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +120 -0
  46. data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +121 -0
  47. data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +64 -0
  48. data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +57 -0
  49. data/spec/sinatra_modular/spec_modular/controller_spec.rb +116 -0
  50. data/spec/sinatra_modular/spec_modular/spec.opts +2 -0
  51. data/spec/sinatra_modular/spec_modular/spec_helper.rb +51 -0
  52. data/spec/sinatra_modular/user.rb +6 -0
  53. data/spec/sinatra_modular/views/test_login.erb +4 -0
  54. metadata +54 -2
data/spec/sinatra/Gemfile CHANGED
@@ -2,9 +2,12 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'sinatra', '>= 1.2.0'
4
4
  gem 'sqlite3-ruby', :require => 'sqlite3'
5
+ gem 'activerecord', '>= 3.0.3'
6
+ gem 'actionmailer', '>= 3.0.3'
5
7
  gem "sorcery", '>= 0.1.0', :path => '../../'
6
8
 
7
9
  group :development, :test do
10
+ gem "rake"
8
11
  gem "rspec", "~> 2.5.0"
9
12
  gem 'ruby-debug19'
10
13
  gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
@@ -1,45 +1,40 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.5.0)
4
+ sorcery (0.5.2)
5
5
  bcrypt-ruby (~> 2.1.4)
6
- json (>= 1.5.1)
7
6
  oauth (>= 0.4.4)
8
7
  oauth (>= 0.4.4)
9
8
  oauth2 (>= 0.1.1)
10
9
  oauth2 (>= 0.1.1)
11
- rails (>= 3.0.0)
12
10
 
13
11
  GEM
14
12
  remote: http://rubygems.org/
15
13
  specs:
16
14
  abstract (1.0.0)
17
- actionmailer (3.0.3)
18
- actionpack (= 3.0.3)
19
- mail (~> 2.2.9)
20
- actionpack (3.0.3)
21
- activemodel (= 3.0.3)
22
- activesupport (= 3.0.3)
15
+ actionmailer (3.0.5)
16
+ actionpack (= 3.0.5)
17
+ mail (~> 2.2.15)
18
+ actionpack (3.0.5)
19
+ activemodel (= 3.0.5)
20
+ activesupport (= 3.0.5)
23
21
  builder (~> 2.1.2)
24
22
  erubis (~> 2.6.6)
25
23
  i18n (~> 0.4)
26
24
  rack (~> 1.2.1)
27
25
  rack-mount (~> 0.6.13)
28
- rack-test (~> 0.5.6)
26
+ rack-test (~> 0.5.7)
29
27
  tzinfo (~> 0.3.23)
30
- activemodel (3.0.3)
31
- activesupport (= 3.0.3)
28
+ activemodel (3.0.5)
29
+ activesupport (= 3.0.5)
32
30
  builder (~> 2.1.2)
33
31
  i18n (~> 0.4)
34
- activerecord (3.0.3)
35
- activemodel (= 3.0.3)
36
- activesupport (= 3.0.3)
32
+ activerecord (3.0.5)
33
+ activemodel (= 3.0.5)
34
+ activesupport (= 3.0.5)
37
35
  arel (~> 2.0.2)
38
36
  tzinfo (~> 0.3.23)
39
- activeresource (3.0.3)
40
- activemodel (= 3.0.3)
41
- activesupport (= 3.0.3)
42
- activesupport (3.0.3)
37
+ activesupport (3.0.5)
43
38
  addressable (2.2.5)
44
39
  archive-tar-minitar (0.5.2)
45
40
  arel (2.0.7)
@@ -54,7 +49,6 @@ GEM
54
49
  multipart-post (~> 1.1.0)
55
50
  rack (< 2, >= 1.1.0)
56
51
  i18n (0.5.0)
57
- json (1.5.1)
58
52
  linecache19 (0.5.11)
59
53
  ruby_core_source (>= 0.1.4)
60
54
  mail (2.2.15)
@@ -75,19 +69,6 @@ GEM
75
69
  rack (>= 1.0.0)
76
70
  rack-test (0.5.7)
77
71
  rack (>= 1.0)
78
- rails (3.0.3)
79
- actionmailer (= 3.0.3)
80
- actionpack (= 3.0.3)
81
- activerecord (= 3.0.3)
82
- activeresource (= 3.0.3)
83
- activesupport (= 3.0.3)
84
- bundler (~> 1.0)
85
- railties (= 3.0.3)
86
- railties (3.0.3)
87
- actionpack (= 3.0.3)
88
- activesupport (= 3.0.3)
89
- rake (>= 0.8.7)
90
- thor (~> 0.14.4)
91
72
  rake (0.8.7)
92
73
  rspec (2.5.0)
93
74
  rspec-core (~> 2.5.0)
@@ -114,7 +95,6 @@ GEM
114
95
  rack (~> 1.1)
115
96
  tilt (< 2.0, >= 1.2.2)
116
97
  sqlite3-ruby (1.3.2)
117
- thor (0.14.6)
118
98
  tilt (1.2.2)
119
99
  timecop (0.3.5)
120
100
  treetop (1.4.9)
@@ -125,6 +105,9 @@ PLATFORMS
125
105
  ruby
126
106
 
127
107
  DEPENDENCIES
108
+ actionmailer (>= 3.0.3)
109
+ activerecord (>= 3.0.3)
110
+ rake
128
111
  rspec (~> 2.5.0)
129
112
  ruby-debug19
130
113
  simplecov (>= 0.3.8)
@@ -6,6 +6,6 @@ task :default => :spec
6
6
 
7
7
  desc "Run all specs"
8
8
  RSpec::Core::RakeTask.new(:spec) do |t|
9
- t.pattern = '**/*_spec.rb'
9
+ t.pattern = 'spec/*_spec.rb'
10
10
  t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec/spec.opts"]
11
11
  end
@@ -1,21 +1,27 @@
1
1
  # --- before filters
2
+ module Filters
2
3
 
3
- ['/test_logout','/some_action','/test_should_be_logged_in'].each do |patt|
4
- before patt do
5
- require_login
6
- end
7
- end
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ ['/test_logout', '/some_action', '/test_should_be_logged_in'].each do |pattern|
7
+ before pattern do
8
+ require_login
9
+ end
10
+ end
8
11
 
9
- before '/test_http_basic_auth' do
10
- require_login_from_http_basic
11
- end
12
+ before '/test_http_basic_auth' do
13
+ require_login_from_http_basic
14
+ end
12
15
 
13
- # ----- test filters
16
+ # ----- test filters
14
17
 
15
- before do
16
- self.class.sorcery_vars = {}
17
- end
18
+ before do
19
+ self.class.sorcery_vars = {}
20
+ end
18
21
 
19
- after do
20
- save_instance_vars
22
+ after do
23
+ save_instance_vars
24
+ end
25
+ end
26
+ end
21
27
  end
@@ -0,0 +1,157 @@
1
+ require 'sinatra/base'
2
+ #enable :sessions
3
+
4
+ require 'sqlite3'
5
+ require 'active_record'
6
+
7
+ # establish connection
8
+ ActiveRecord::Base.establish_connection(
9
+ :adapter => "sqlite3",
10
+ :database => ":memory:",
11
+ :verbosity => "quiet"
12
+ )
13
+
14
+ require 'action_mailer'
15
+ ActionMailer::Base.delivery_method = :test
16
+ require File.join(File.dirname(__FILE__), 'sorcery_mailer')
17
+
18
+ # models
19
+ require File.join(File.dirname(__FILE__), 'user')
20
+ require 'sorcery'
21
+
22
+ APP_ROOT = File.dirname(__FILE__)
23
+
24
+ class Modular < Sinatra::Base
25
+ set :sessions, true
26
+
27
+ # ['/test_logout', '/some_action', '/test_should_be_logged_in'].each do |patt|
28
+ # before patt do
29
+ # require_login
30
+ # end
31
+ # end
32
+ #
33
+ # before '/test_http_basic_auth' do
34
+ # require_login_from_http_basic
35
+ # end
36
+ #
37
+ ## ----- test filters
38
+ #
39
+ # before do
40
+ # self.class.sorcery_vars = {}
41
+ # end
42
+ #
43
+ # after do
44
+ # save_instance_vars
45
+ # end
46
+
47
+ get '/' do
48
+
49
+ end
50
+
51
+ get '/test_login' do
52
+ @user = login(params[:username], params[:password])
53
+ @current_user = current_user
54
+ @logged_in = logged_in?
55
+ erb :test_login
56
+ end
57
+
58
+ get '/test_logout' do
59
+ session[:user_id] = User.first.id
60
+ logout
61
+ @current_user = current_user
62
+ @logged_in = logged_in?
63
+ end
64
+
65
+ get '/test_current_user' do
66
+ session[:user_id] = params[:id]
67
+ current_user
68
+ end
69
+
70
+ get '/some_action' do
71
+ erb ''
72
+ end
73
+
74
+ post '/test_return_to' do
75
+ session[:return_to_url] = params[:return_to_url] if params[:return_to_url]
76
+ @user = login(params[:username], params[:password])
77
+ redirect_back_or_to(:some_action)
78
+ end
79
+
80
+ get '/test_should_be_logged_in' do
81
+ erb ''
82
+ end
83
+
84
+ def test_not_authenticated_action
85
+ halt "test_not_authenticated_action"
86
+ end
87
+
88
+ def not_authenticated2
89
+ @session = session
90
+ save_instance_vars
91
+ redirect '/'
92
+ end
93
+
94
+ # remember me
95
+
96
+ post '/test_login_with_remember' do
97
+ @user = login(params[:username], params[:password])
98
+ remember_me!
99
+ erb ''
100
+ end
101
+
102
+ post '/test_login_with_remember_in_login' do
103
+ @user = login(params[:username], params[:password], params[:remember])
104
+ erb ''
105
+ end
106
+
107
+ get '/test_login_from_cookie' do
108
+ @user = current_user
109
+ erb ''
110
+ end
111
+
112
+ # http_basic
113
+
114
+ get '/test_http_basic_auth' do
115
+ erb "HTTP Basic Auth"
116
+ end
117
+
118
+ # oauth
119
+
120
+ get '/login_at_test' do
121
+ login_at(:twitter)
122
+ end
123
+
124
+ get '/test_login_from' do
125
+ if @user = login_from(:twitter)
126
+ erb "Success!"
127
+ else
128
+ erb "Failed!"
129
+ end
130
+ end
131
+
132
+ # oauth2
133
+
134
+ get '/login_at_test2' do
135
+ login_at(:facebook)
136
+ end
137
+
138
+ get '/test_login_from2' do
139
+ if @user = login_from(:facebook)
140
+ erb "Success!"
141
+ else
142
+ erb "Failed!"
143
+ end
144
+ end
145
+
146
+ get '/test_create_from_provider' do
147
+ provider = params[:provider]
148
+ login_from(provider)
149
+ if @user = create_from(provider)
150
+ erb "Success!"
151
+ else
152
+ erb "Failed!"
153
+ end
154
+ end
155
+
156
+ #run! if app_file == $2
157
+ end
@@ -0,0 +1,15 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sinatra', '>= 1.2.0'
4
+ gem 'sqlite3-ruby', :require => 'sqlite3'
5
+ gem 'activerecord', '>= 3.0.3'
6
+ gem 'actionmailer', '>= 3.0.3'
7
+ gem "sorcery", '>= 0.1.0', :path => '../../'
8
+
9
+ group :development, :test do
10
+ gem "rake"
11
+ gem "rspec", "~> 2.5.0"
12
+ gem 'ruby-debug19'
13
+ gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
14
+ gem 'timecop'
15
+ end
@@ -0,0 +1,117 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ sorcery (0.5.2)
5
+ bcrypt-ruby (~> 2.1.4)
6
+ oauth (>= 0.4.4)
7
+ oauth (>= 0.4.4)
8
+ oauth2 (>= 0.1.1)
9
+ oauth2 (>= 0.1.1)
10
+
11
+ GEM
12
+ remote: http://rubygems.org/
13
+ specs:
14
+ abstract (1.0.0)
15
+ actionmailer (3.0.5)
16
+ actionpack (= 3.0.5)
17
+ mail (~> 2.2.15)
18
+ actionpack (3.0.5)
19
+ activemodel (= 3.0.5)
20
+ activesupport (= 3.0.5)
21
+ builder (~> 2.1.2)
22
+ erubis (~> 2.6.6)
23
+ i18n (~> 0.4)
24
+ rack (~> 1.2.1)
25
+ rack-mount (~> 0.6.13)
26
+ rack-test (~> 0.5.7)
27
+ tzinfo (~> 0.3.23)
28
+ activemodel (3.0.5)
29
+ activesupport (= 3.0.5)
30
+ builder (~> 2.1.2)
31
+ i18n (~> 0.4)
32
+ activerecord (3.0.5)
33
+ activemodel (= 3.0.5)
34
+ activesupport (= 3.0.5)
35
+ arel (~> 2.0.2)
36
+ tzinfo (~> 0.3.23)
37
+ activesupport (3.0.5)
38
+ addressable (2.2.5)
39
+ archive-tar-minitar (0.5.2)
40
+ arel (2.0.7)
41
+ bcrypt-ruby (2.1.4)
42
+ builder (2.1.2)
43
+ columnize (0.3.2)
44
+ diff-lcs (1.1.2)
45
+ erubis (2.6.6)
46
+ abstract (>= 1.0.0)
47
+ faraday (0.6.1)
48
+ addressable (~> 2.2.4)
49
+ multipart-post (~> 1.1.0)
50
+ rack (< 2, >= 1.1.0)
51
+ i18n (0.5.0)
52
+ linecache19 (0.5.11)
53
+ ruby_core_source (>= 0.1.4)
54
+ mail (2.2.15)
55
+ activesupport (>= 2.3.6)
56
+ i18n (>= 0.4.0)
57
+ mime-types (~> 1.16)
58
+ treetop (~> 1.4.8)
59
+ mime-types (1.16)
60
+ multi_json (1.0.1)
61
+ multipart-post (1.1.0)
62
+ oauth (0.4.4)
63
+ oauth2 (0.4.1)
64
+ faraday (~> 0.6.1)
65
+ multi_json (>= 0.0.5)
66
+ polyglot (0.3.1)
67
+ rack (1.2.1)
68
+ rack-mount (0.6.14)
69
+ rack (>= 1.0.0)
70
+ rack-test (0.5.7)
71
+ rack (>= 1.0)
72
+ rake (0.8.7)
73
+ rspec (2.5.0)
74
+ rspec-core (~> 2.5.0)
75
+ rspec-expectations (~> 2.5.0)
76
+ rspec-mocks (~> 2.5.0)
77
+ rspec-core (2.5.1)
78
+ rspec-expectations (2.5.0)
79
+ diff-lcs (~> 1.1.2)
80
+ rspec-mocks (2.5.0)
81
+ ruby-debug-base19 (0.11.24)
82
+ columnize (>= 0.3.1)
83
+ linecache19 (>= 0.5.11)
84
+ ruby_core_source (>= 0.1.4)
85
+ ruby-debug19 (0.11.6)
86
+ columnize (>= 0.3.1)
87
+ linecache19 (>= 0.5.11)
88
+ ruby-debug-base19 (>= 0.11.19)
89
+ ruby_core_source (0.1.4)
90
+ archive-tar-minitar (>= 0.5.2)
91
+ simplecov (0.3.9)
92
+ simplecov-html (>= 0.3.7)
93
+ simplecov-html (0.3.9)
94
+ sinatra (1.2.0)
95
+ rack (~> 1.1)
96
+ tilt (< 2.0, >= 1.2.2)
97
+ sqlite3-ruby (1.3.2)
98
+ tilt (1.2.2)
99
+ timecop (0.3.5)
100
+ treetop (1.4.9)
101
+ polyglot (>= 0.3.1)
102
+ tzinfo (0.3.24)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ actionmailer (>= 3.0.3)
109
+ activerecord (>= 3.0.3)
110
+ rake
111
+ rspec (~> 2.5.0)
112
+ ruby-debug19
113
+ simplecov (>= 0.3.8)
114
+ sinatra (>= 1.2.0)
115
+ sorcery (>= 0.1.0)!
116
+ sqlite3-ruby
117
+ timecop
@@ -0,0 +1,11 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Default: Run all specs.'
5
+ task :default => :spec
6
+
7
+ desc "Run all specs"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec_modular/*_spec.rb'
10
+ t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec_modular/spec.opts"]
11
+ end
@@ -0,0 +1,3 @@
1
+ class Authentication < ActiveRecord::Base
2
+ belongs_to :user
3
+ end
@@ -0,0 +1,17 @@
1
+ class AddActivationToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :activation_state, :string, :default => nil
4
+ add_column :users, :activation_token, :string, :default => nil
5
+ add_column :users, :activation_token_expires_at, :datetime, :default => nil
6
+
7
+ add_index :users, :activation_token
8
+ end
9
+
10
+ def self.down
11
+ remove_index :users, :activation_token
12
+
13
+ remove_column :users, :activation_token_expires_at
14
+ remove_column :users, :activation_token
15
+ remove_column :users, :activation_state
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ class AddActivityLoggingToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :last_login_at, :datetime, :default => nil
4
+ add_column :users, :last_logout_at, :datetime, :default => nil
5
+ add_column :users, :last_activity_at, :datetime, :default => nil
6
+
7
+ add_index :users, [:last_logout_at, :last_activity_at]
8
+ end
9
+
10
+ def self.down
11
+ remove_index :users, [:last_logout_at, :last_activity_at]
12
+
13
+ remove_column :users, :last_activity_at
14
+ remove_column :users, :last_logout_at
15
+ remove_column :users, :last_login_at
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ class AddBruteForceProtectionToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :failed_logins_count, :integer, :default => 0
4
+ add_column :users, :lock_expires_at, :datetime, :default => nil
5
+ end
6
+
7
+ def self.down
8
+ remove_column :users, :lock_expires_at
9
+ remove_column :users, :failed_logins_count
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :username, :null => false
5
+ t.string :email, :default => nil
6
+ t.string :crypted_password, :default => nil
7
+ t.string :salt, :default => nil
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :users
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ class CreateAuthentications < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :authentications do |t|
4
+ t.integer :user_id, :null => false
5
+ t.string :provider, :uid, :null => false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :authentications
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class AddRememberMeTokenToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :remember_me_token, :string, :default => nil
4
+ add_column :users, :remember_me_token_expires_at, :datetime, :default => nil
5
+
6
+ add_index :users, :remember_me_token
7
+ end
8
+
9
+ def self.down
10
+ remove_index :users, :remember_me_token
11
+
12
+ remove_column :users, :remember_me_token_expires_at
13
+ remove_column :users, :remember_me_token
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class AddResetPasswordToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :reset_password_token, :string, :default => nil
4
+ add_column :users, :reset_password_token_expires_at, :datetime, :default => nil
5
+ add_column :users, :reset_password_email_sent_at, :datetime, :default => nil
6
+ end
7
+
8
+ def self.down
9
+ remove_column :users, :reset_password_email_sent_at
10
+ remove_column :users, :reset_password_token_expires_at
11
+ remove_column :users, :reset_password_token
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ # --- before filters
2
+ module Filters
3
+
4
+ def self.included(klass)
5
+ klass.class_eval do
6
+ ['/test_logout', '/some_action', '/test_should_be_logged_in'].each do |pattern|
7
+ before pattern do
8
+ require_login
9
+ end
10
+ end
11
+
12
+ before '/test_http_basic_auth' do
13
+ require_login_from_http_basic
14
+ end
15
+
16
+ # ----- test filters
17
+
18
+ before do
19
+ self.class.sorcery_vars = {}
20
+ end
21
+
22
+ after do
23
+ save_instance_vars
24
+ end
25
+ end
26
+ end
27
+ end