devise 1.1.3 → 1.2.0
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/.gitignore +10 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.rdoc +94 -0
- data/Gemfile +24 -13
- data/Gemfile.lock +119 -75
- data/MIT-LICENSE +1 -1
- data/README.rdoc +144 -101
- data/Rakefile +3 -24
- data/app/controllers/devise/confirmations_controller.rb +1 -1
- data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
- data/app/controllers/devise/passwords_controller.rb +1 -1
- data/app/controllers/devise/registrations_controller.rb +60 -7
- data/app/controllers/devise/sessions_controller.rb +6 -4
- data/app/controllers/devise/unlocks_controller.rb +1 -1
- data/app/helpers/devise_helper.rb +10 -2
- data/app/mailers/devise/mailer.rb +27 -10
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +2 -2
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/shared/_links.erb +6 -0
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +11 -2
- data/devise.gemspec +25 -0
- data/lib/devise/controllers/helpers.rb +119 -116
- data/lib/devise/controllers/internal_helpers.rb +29 -8
- data/lib/devise/controllers/rememberable.rb +52 -0
- data/lib/devise/controllers/scoped_views.rb +4 -6
- data/lib/devise/controllers/url_helpers.rb +3 -5
- data/lib/devise/encryptors/authlogic_sha512.rb +1 -1
- data/lib/devise/encryptors/base.rb +1 -1
- data/lib/devise/encryptors/restful_authentication_sha1.rb +4 -4
- data/lib/devise/failure_app.rb +46 -10
- data/lib/devise/hooks/activatable.rb +2 -2
- data/lib/devise/hooks/forgetable.rb +1 -3
- data/lib/devise/hooks/rememberable.rb +5 -42
- data/lib/devise/hooks/timeoutable.rb +1 -1
- data/lib/devise/mapping.rb +18 -7
- data/lib/devise/models/authenticatable.rb +73 -31
- data/lib/devise/models/confirmable.rb +16 -20
- data/lib/devise/models/database_authenticatable.rb +27 -37
- data/lib/devise/models/encryptable.rb +72 -0
- data/lib/devise/models/lockable.rb +27 -21
- data/lib/devise/models/omniauthable.rb +23 -0
- data/lib/devise/models/recoverable.rb +13 -3
- data/lib/devise/models/registerable.rb +13 -0
- data/lib/devise/models/rememberable.rb +39 -34
- data/lib/devise/models/timeoutable.rb +20 -3
- data/lib/devise/models/token_authenticatable.rb +22 -10
- data/lib/devise/models/validatable.rb +16 -4
- data/lib/devise/models.rb +4 -16
- data/lib/devise/modules.rb +15 -8
- data/lib/devise/omniauth/config.rb +18 -0
- data/lib/devise/omniauth/url_helpers.rb +33 -0
- data/lib/devise/omniauth.rb +32 -0
- data/lib/devise/orm/active_record.rb +2 -0
- data/lib/devise/orm/mongoid.rb +4 -2
- data/lib/devise/rails/routes.rb +67 -20
- data/lib/devise/rails/warden_compat.rb +101 -15
- data/lib/devise/rails.rb +33 -44
- data/lib/devise/schema.rb +16 -16
- data/lib/devise/strategies/authenticatable.rb +48 -7
- data/lib/devise/strategies/database_authenticatable.rb +1 -1
- data/lib/devise/strategies/rememberable.rb +6 -5
- data/lib/devise/strategies/token_authenticatable.rb +6 -2
- data/lib/devise/test_helpers.rb +13 -3
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +162 -50
- data/lib/generators/active_record/devise_generator.rb +2 -2
- data/lib/generators/active_record/templates/migration.rb +2 -0
- data/lib/generators/devise/devise_generator.rb +3 -1
- data/lib/generators/devise/orm_helpers.rb +1 -1
- data/lib/generators/devise/views_generator.rb +8 -45
- data/lib/generators/mongoid/devise_generator.rb +2 -2
- data/lib/generators/templates/devise.rb +82 -39
- data/test/controllers/helpers_test.rb +78 -72
- data/test/controllers/internal_helpers_test.rb +29 -8
- data/test/controllers/url_helpers_test.rb +2 -1
- data/test/devise_test.rb +10 -0
- data/test/failure_app_test.rb +86 -22
- data/test/generators/active_record_generator_test.rb +24 -0
- data/test/generators/devise_generator_test.rb +33 -0
- data/test/generators/install_generator_test.rb +13 -0
- data/test/generators/mongoid_generator_test.rb +22 -0
- data/test/generators/views_generator_test.rb +35 -0
- data/test/indifferent_hash.rb +33 -0
- data/test/integration/authenticatable_test.rb +165 -62
- data/test/integration/database_authenticatable_test.rb +22 -0
- data/test/integration/http_authenticatable_test.rb +12 -2
- data/test/integration/omniauthable_test.rb +138 -0
- data/test/integration/recoverable_test.rb +39 -20
- data/test/integration/registerable_test.rb +60 -4
- data/test/integration/rememberable_test.rb +72 -29
- data/test/integration/timeoutable_test.rb +10 -1
- data/test/integration/token_authenticatable_test.rb +55 -6
- data/test/mailers/confirmation_instructions_test.rb +4 -0
- data/test/mailers/reset_password_instructions_test.rb +4 -0
- data/test/mailers/unlock_instructions_test.rb +4 -0
- data/test/mapping_test.rb +37 -3
- data/test/models/confirmable_test.rb +32 -15
- data/test/models/database_authenticatable_test.rb +14 -71
- data/test/models/encryptable_test.rb +65 -0
- data/test/models/lockable_test.rb +48 -11
- data/test/models/recoverable_test.rb +28 -2
- data/test/models/rememberable_test.rb +186 -125
- data/test/models/token_authenticatable_test.rb +19 -1
- data/test/models_test.rb +12 -5
- data/test/omniauth/url_helpers_test.rb +54 -0
- data/test/orm/mongoid.rb +3 -2
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/admin.rb +4 -1
- data/test/rails_app/app/active_record/user.rb +5 -4
- data/test/rails_app/app/controllers/{sessions_controller.rb → admins/sessions_controller.rb} +1 -1
- data/test/rails_app/app/controllers/application_controller.rb +0 -1
- data/test/rails_app/app/controllers/home_controller.rb +9 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
- data/test/rails_app/app/mongoid/admin.rb +4 -1
- data/test/rails_app/app/mongoid/shim.rb +16 -3
- data/test/rails_app/app/mongoid/user.rb +5 -5
- data/test/rails_app/app/views/admins/index.html.erb +1 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/home/private.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +24 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
- data/test/rails_app/config/application.rb +5 -0
- data/test/rails_app/config/boot.rb +2 -2
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/initializers/devise.rb +71 -31
- data/test/rails_app/config/routes.rb +14 -6
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +21 -17
- data/test/rails_app/db/schema.rb +17 -51
- data/test/rails_app/lib/shared_admin.rb +9 -0
- data/test/rails_app/lib/shared_user.rb +23 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +10 -0
- data/test/routes_test.rb +42 -9
- data/test/schema_test.rb +33 -0
- data/test/support/integration.rb +4 -4
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +11 -19
- data/test/test_helper.rb +8 -2
- data/test/test_helpers_test.rb +64 -2
- metadata +106 -30
- data/TODO +0 -3
- data/lib/devise/encryptors/bcrypt.rb +0 -19
- data/lib/generators/devise_install_generator.rb +0 -4
- data/lib/generators/devise_views_generator.rb +0 -4
- data/test/support/test_silencer.rb +0 -5
data/test/routes_test.rb
CHANGED
|
@@ -86,10 +86,25 @@ class DefaultRoutingTest < ActionController::TestCase
|
|
|
86
86
|
assert_recognizes({:controller => 'devise/registrations', :action => 'destroy'}, {:path => 'users', :method => :delete})
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
+
test 'map cancel user registration' do
|
|
90
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel'}, {:path => 'users/cancel', :method => :get})
|
|
91
|
+
assert_named_route "/users/cancel", :cancel_user_registration_path
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
test 'map omniauth callbacks' do
|
|
95
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :get})
|
|
96
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :post})
|
|
97
|
+
assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
|
|
98
|
+
|
|
99
|
+
assert_raise ActionController::RoutingError do
|
|
100
|
+
assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
89
104
|
protected
|
|
90
105
|
|
|
91
|
-
def assert_named_route(result,
|
|
92
|
-
assert_equal result, @routes.url_helpers.send(
|
|
106
|
+
def assert_named_route(result, *args)
|
|
107
|
+
assert_equal result, @routes.url_helpers.send(*args)
|
|
93
108
|
end
|
|
94
109
|
end
|
|
95
110
|
|
|
@@ -99,7 +114,7 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|
|
99
114
|
end
|
|
100
115
|
|
|
101
116
|
test 'map admin with :controllers option' do
|
|
102
|
-
assert_recognizes({:controller => 'sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
|
|
117
|
+
assert_recognizes({:controller => 'admins/sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
|
|
103
118
|
end
|
|
104
119
|
|
|
105
120
|
test 'does not map admin password' do
|
|
@@ -120,16 +135,34 @@ class CustomizedRoutingTest < ActionController::TestCase
|
|
|
120
135
|
assert_recognizes({:controller => 'devise/passwords', :action => 'new', :locale => 'en'}, '/en/accounts/secret/new')
|
|
121
136
|
end
|
|
122
137
|
|
|
123
|
-
test 'map account with custom path name for
|
|
124
|
-
assert_recognizes({:controller => 'devise/
|
|
138
|
+
test 'map account with custom path name for registration' do
|
|
139
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
|
|
125
140
|
end
|
|
126
141
|
|
|
127
|
-
test 'map account with custom path name for
|
|
128
|
-
assert_recognizes({:controller => 'devise/
|
|
142
|
+
test 'map account with custom path name for cancel registration' do
|
|
143
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel', :locale => 'en'}, '/en/accounts/management/giveup')
|
|
129
144
|
end
|
|
130
145
|
|
|
131
|
-
test 'map
|
|
132
|
-
assert_recognizes({:controller => 'devise/
|
|
146
|
+
test 'map deletes with :sign_out_via option' do
|
|
147
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :delete})
|
|
148
|
+
assert_raise ActionController::RoutingError do
|
|
149
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :get})
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
test 'map posts with :sign_out_via option' do
|
|
154
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :post})
|
|
155
|
+
assert_raise ActionController::RoutingError do
|
|
156
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :get})
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
test 'map delete_or_posts with :sign_out_via option' do
|
|
161
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :post})
|
|
162
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :delete})
|
|
163
|
+
assert_raise ActionController::RoutingError do
|
|
164
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
|
|
165
|
+
end
|
|
133
166
|
end
|
|
134
167
|
end
|
|
135
168
|
|
data/test/schema_test.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
if DEVISE_ORM == :mongoid
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class User2
|
|
6
|
+
include Mongoid::Document
|
|
7
|
+
devise :database_authenticatable
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class User3
|
|
11
|
+
include Mongoid::Document
|
|
12
|
+
devise :database_authenticatable, :authentication_keys => [:username, :email]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class User4
|
|
16
|
+
include Mongoid::Document
|
|
17
|
+
devise :database_authenticatable, :authentication_keys => [:username]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class SchemaTest < ActiveSupport::TestCase
|
|
21
|
+
test 'should create an email field if there are no custom authentication keys' do
|
|
22
|
+
assert_not_equal User2.fields['email'], nil
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test 'should create an email field if there are custom authentication keys and they include email' do
|
|
26
|
+
assert_not_equal User3.fields['email'], nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'should not create an email field if there are custom authentication keys they don\'t include email' do
|
|
30
|
+
assert_equal User4.fields['email'], nil
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/test/support/integration.rb
CHANGED
|
@@ -9,9 +9,9 @@ class ActionDispatch::IntegrationTest
|
|
|
9
9
|
@user ||= begin
|
|
10
10
|
user = User.create!(
|
|
11
11
|
:username => 'usertest',
|
|
12
|
-
:email => 'user@test.com',
|
|
13
|
-
:password => '123456',
|
|
14
|
-
:password_confirmation => '123456',
|
|
12
|
+
:email => options[:email] || 'user@test.com',
|
|
13
|
+
:password => options[:password] || '123456',
|
|
14
|
+
:password_confirmation => options[:password] || '123456',
|
|
15
15
|
:created_at => Time.now.utc
|
|
16
16
|
)
|
|
17
17
|
user.confirm! unless options[:confirm] == false
|
|
@@ -32,7 +32,7 @@ class ActionDispatch::IntegrationTest
|
|
|
32
32
|
def sign_in_as_user(options={}, &block)
|
|
33
33
|
user = create_user(options)
|
|
34
34
|
visit_with_option options[:visit], new_user_session_path
|
|
35
|
-
fill_in 'email', :with => 'user@test.com'
|
|
35
|
+
fill_in 'email', :with => options[:email] || 'user@test.com'
|
|
36
36
|
fill_in 'password', :with => options[:password] || '123456'
|
|
37
37
|
check 'remember me' if options[:remember_me] == true
|
|
38
38
|
yield if block_given?
|
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
require 'webrat/core/elements/
|
|
1
|
+
require 'webrat/core/elements/form'
|
|
2
2
|
require 'action_dispatch/testing/integration'
|
|
3
3
|
|
|
4
4
|
module Webrat
|
|
5
|
-
|
|
6
|
-
def parse_rails_request_params(params)
|
|
5
|
+
Form.class_eval do
|
|
6
|
+
def self.parse_rails_request_params(params)
|
|
7
7
|
Rack::Utils.parse_nested_query(params)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
module Logging
|
|
12
|
+
# Avoid RAILS_DEFAULT_LOGGER deprecation warning
|
|
13
|
+
def logger # :nodoc:
|
|
14
|
+
::Rails.logger
|
|
15
|
+
end
|
|
16
|
+
end
|
|
10
17
|
end
|
|
11
18
|
|
|
12
19
|
module ActionDispatch #:nodoc:
|
|
13
20
|
IntegrationTest.class_eval do
|
|
14
21
|
include Webrat::Methods
|
|
15
22
|
include Webrat::Matchers
|
|
16
|
-
|
|
17
|
-
# The Rails version of within supports passing in a model and Webrat
|
|
18
|
-
# will apply a scope based on Rails' dom_id for that model.
|
|
19
|
-
#
|
|
20
|
-
# Example:
|
|
21
|
-
# within User.last do
|
|
22
|
-
# click_link "Delete"
|
|
23
|
-
# end
|
|
24
|
-
def within(selector_or_object, &block)
|
|
25
|
-
if selector_or_object.is_a?(String)
|
|
26
|
-
super
|
|
27
|
-
else
|
|
28
|
-
super('#' + RecordIdentifier.dom_id(selector_or_object), &block)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
23
|
end
|
|
32
|
-
end
|
|
24
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -9,8 +9,9 @@ require "rails/test_help"
|
|
|
9
9
|
require "orm/#{DEVISE_ORM}"
|
|
10
10
|
|
|
11
11
|
I18n.load_path << File.expand_path("../support/locale/en.yml", __FILE__)
|
|
12
|
-
require 'mocha'
|
|
13
12
|
|
|
13
|
+
require 'mocha'
|
|
14
|
+
require 'webrat'
|
|
14
15
|
Webrat.configure do |config|
|
|
15
16
|
config.mode = :rails
|
|
16
17
|
config.open_error_files = false
|
|
@@ -18,4 +19,9 @@ end
|
|
|
18
19
|
|
|
19
20
|
# Add support to load paths so we can overwrite broken webrat setup
|
|
20
21
|
$:.unshift File.expand_path('../support', __FILE__)
|
|
21
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
23
|
+
|
|
24
|
+
# For generators
|
|
25
|
+
require "rails/generators/test_case"
|
|
26
|
+
require "generators/devise/install_generator"
|
|
27
|
+
require "generators/devise/views_generator"
|
data/test/test_helpers_test.rb
CHANGED
|
@@ -4,6 +4,12 @@ class TestHelpersTest < ActionController::TestCase
|
|
|
4
4
|
tests UsersController
|
|
5
5
|
include Devise::TestHelpers
|
|
6
6
|
|
|
7
|
+
class CustomFailureApp < Devise::FailureApp
|
|
8
|
+
def redirect
|
|
9
|
+
self.status = 306
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
test "redirects if attempting to access a page unauthenticated" do
|
|
8
14
|
get :index
|
|
9
15
|
assert_redirected_to new_user_session_path
|
|
@@ -13,7 +19,7 @@ class TestHelpersTest < ActionController::TestCase
|
|
|
13
19
|
test "redirects if attempting to access a page with an unconfirmed account" do
|
|
14
20
|
swap Devise, :confirm_within => 0 do
|
|
15
21
|
user = create_user
|
|
16
|
-
assert !user.
|
|
22
|
+
assert !user.active_for_authentication?
|
|
17
23
|
|
|
18
24
|
sign_in user
|
|
19
25
|
get :index
|
|
@@ -24,7 +30,7 @@ class TestHelpersTest < ActionController::TestCase
|
|
|
24
30
|
test "returns nil if accessing current_user with an unconfirmed account" do
|
|
25
31
|
swap Devise, :confirm_within => 0 do
|
|
26
32
|
user = create_user
|
|
27
|
-
assert !user.
|
|
33
|
+
assert !user.active_for_authentication?
|
|
28
34
|
|
|
29
35
|
sign_in user
|
|
30
36
|
get :accept, :id => user
|
|
@@ -52,6 +58,62 @@ class TestHelpersTest < ActionController::TestCase
|
|
|
52
58
|
get :index
|
|
53
59
|
assert_redirected_to new_user_session_path
|
|
54
60
|
end
|
|
61
|
+
|
|
62
|
+
test "respects custom failure app" do
|
|
63
|
+
begin
|
|
64
|
+
Devise.warden_config.failure_app = CustomFailureApp
|
|
65
|
+
get :index
|
|
66
|
+
assert_response 306
|
|
67
|
+
ensure
|
|
68
|
+
Devise.warden_config.failure_app = Devise::FailureApp
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
test "defined Warden after_authentication callback should not be called when sign_in is called" do
|
|
73
|
+
begin
|
|
74
|
+
Warden::Manager.after_authentication do |user, auth, opts|
|
|
75
|
+
flunk "callback was called while it should not"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
user = create_user
|
|
79
|
+
user.confirm!
|
|
80
|
+
sign_in user
|
|
81
|
+
ensure
|
|
82
|
+
Warden::Manager._after_set_user.pop
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
test "defined Warden before_logout callback should not be called when sign_out is called" do
|
|
87
|
+
begin
|
|
88
|
+
Warden::Manager.before_logout do |user, auth, opts|
|
|
89
|
+
flunk "callback was called while it should not"
|
|
90
|
+
end
|
|
91
|
+
user = create_user
|
|
92
|
+
user.confirm!
|
|
93
|
+
|
|
94
|
+
sign_in user
|
|
95
|
+
sign_out user
|
|
96
|
+
ensure
|
|
97
|
+
Warden::Manager._before_logout.pop
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
test "before_failure call should work" do
|
|
102
|
+
begin
|
|
103
|
+
executed = false
|
|
104
|
+
Warden::Manager.before_failure do |env,opts|
|
|
105
|
+
executed = true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
user = create_user
|
|
109
|
+
sign_in user
|
|
110
|
+
|
|
111
|
+
get :index
|
|
112
|
+
assert executed
|
|
113
|
+
ensure
|
|
114
|
+
Warden::Manager._before_failure.pop
|
|
115
|
+
end
|
|
116
|
+
end
|
|
55
117
|
|
|
56
118
|
test "allows to sign in with different users" do
|
|
57
119
|
first_user = create_user
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: devise
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 31
|
|
5
|
+
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 1.
|
|
8
|
+
- 2
|
|
9
|
+
- 0
|
|
10
|
+
version: 1.2.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date:
|
|
19
|
+
date: 2011-03-25 00:00:00 +01:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
@@ -27,18 +27,34 @@ dependencies:
|
|
|
27
27
|
requirements:
|
|
28
28
|
- - ~>
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
hash:
|
|
30
|
+
hash: 17
|
|
31
31
|
segments:
|
|
32
|
+
- 1
|
|
32
33
|
- 0
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
version: 0.10.7
|
|
34
|
+
- 3
|
|
35
|
+
version: 1.0.3
|
|
36
36
|
type: :runtime
|
|
37
37
|
version_requirements: *id001
|
|
38
38
|
- !ruby/object:Gem::Dependency
|
|
39
|
-
name:
|
|
39
|
+
name: orm_adapter
|
|
40
40
|
prerelease: false
|
|
41
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ~>
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
hash: 25
|
|
47
|
+
segments:
|
|
48
|
+
- 0
|
|
49
|
+
- 0
|
|
50
|
+
- 3
|
|
51
|
+
version: 0.0.3
|
|
52
|
+
type: :runtime
|
|
53
|
+
version_requirements: *id002
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: bcrypt-ruby
|
|
56
|
+
prerelease: false
|
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
42
58
|
none: false
|
|
43
59
|
requirements:
|
|
44
60
|
- - ~>
|
|
@@ -50,28 +66,26 @@ dependencies:
|
|
|
50
66
|
- 2
|
|
51
67
|
version: 2.1.2
|
|
52
68
|
type: :runtime
|
|
53
|
-
version_requirements: *
|
|
69
|
+
version_requirements: *id003
|
|
54
70
|
description: Flexible authentication solution for Rails with Warden
|
|
55
71
|
email: contact@plataformatec.com.br
|
|
56
72
|
executables: []
|
|
57
73
|
|
|
58
74
|
extensions: []
|
|
59
75
|
|
|
60
|
-
extra_rdoc_files:
|
|
61
|
-
|
|
62
|
-
- Gemfile.lock
|
|
63
|
-
- MIT-LICENSE
|
|
64
|
-
- README.rdoc
|
|
65
|
-
- TODO
|
|
76
|
+
extra_rdoc_files: []
|
|
77
|
+
|
|
66
78
|
files:
|
|
79
|
+
- .gitignore
|
|
80
|
+
- .travis.yml
|
|
67
81
|
- CHANGELOG.rdoc
|
|
68
82
|
- Gemfile
|
|
69
83
|
- Gemfile.lock
|
|
70
84
|
- MIT-LICENSE
|
|
71
85
|
- README.rdoc
|
|
72
86
|
- Rakefile
|
|
73
|
-
- TODO
|
|
74
87
|
- app/controllers/devise/confirmations_controller.rb
|
|
88
|
+
- app/controllers/devise/omniauth_callbacks_controller.rb
|
|
75
89
|
- app/controllers/devise/passwords_controller.rb
|
|
76
90
|
- app/controllers/devise/registrations_controller.rb
|
|
77
91
|
- app/controllers/devise/sessions_controller.rb
|
|
@@ -90,14 +104,15 @@ files:
|
|
|
90
104
|
- app/views/devise/shared/_links.erb
|
|
91
105
|
- app/views/devise/unlocks/new.html.erb
|
|
92
106
|
- config/locales/en.yml
|
|
107
|
+
- devise.gemspec
|
|
93
108
|
- lib/devise.rb
|
|
94
109
|
- lib/devise/controllers/helpers.rb
|
|
95
110
|
- lib/devise/controllers/internal_helpers.rb
|
|
111
|
+
- lib/devise/controllers/rememberable.rb
|
|
96
112
|
- lib/devise/controllers/scoped_views.rb
|
|
97
113
|
- lib/devise/controllers/url_helpers.rb
|
|
98
114
|
- lib/devise/encryptors/authlogic_sha512.rb
|
|
99
115
|
- lib/devise/encryptors/base.rb
|
|
100
|
-
- lib/devise/encryptors/bcrypt.rb
|
|
101
116
|
- lib/devise/encryptors/clearance_sha1.rb
|
|
102
117
|
- lib/devise/encryptors/restful_authentication_sha1.rb
|
|
103
118
|
- lib/devise/encryptors/sha1.rb
|
|
@@ -113,7 +128,9 @@ files:
|
|
|
113
128
|
- lib/devise/models/authenticatable.rb
|
|
114
129
|
- lib/devise/models/confirmable.rb
|
|
115
130
|
- lib/devise/models/database_authenticatable.rb
|
|
131
|
+
- lib/devise/models/encryptable.rb
|
|
116
132
|
- lib/devise/models/lockable.rb
|
|
133
|
+
- lib/devise/models/omniauthable.rb
|
|
117
134
|
- lib/devise/models/recoverable.rb
|
|
118
135
|
- lib/devise/models/registerable.rb
|
|
119
136
|
- lib/devise/models/rememberable.rb
|
|
@@ -122,6 +139,9 @@ files:
|
|
|
122
139
|
- lib/devise/models/trackable.rb
|
|
123
140
|
- lib/devise/models/validatable.rb
|
|
124
141
|
- lib/devise/modules.rb
|
|
142
|
+
- lib/devise/omniauth.rb
|
|
143
|
+
- lib/devise/omniauth/config.rb
|
|
144
|
+
- lib/devise/omniauth/url_helpers.rb
|
|
125
145
|
- lib/devise/orm/active_record.rb
|
|
126
146
|
- lib/devise/orm/mongoid.rb
|
|
127
147
|
- lib/devise/path_checker.rb
|
|
@@ -142,8 +162,6 @@ files:
|
|
|
142
162
|
- lib/generators/devise/install_generator.rb
|
|
143
163
|
- lib/generators/devise/orm_helpers.rb
|
|
144
164
|
- lib/generators/devise/views_generator.rb
|
|
145
|
-
- lib/generators/devise_install_generator.rb
|
|
146
|
-
- lib/generators/devise_views_generator.rb
|
|
147
165
|
- lib/generators/mongoid/devise_generator.rb
|
|
148
166
|
- lib/generators/templates/README
|
|
149
167
|
- lib/generators/templates/devise.rb
|
|
@@ -153,11 +171,18 @@ files:
|
|
|
153
171
|
- test/devise_test.rb
|
|
154
172
|
- test/encryptors_test.rb
|
|
155
173
|
- test/failure_app_test.rb
|
|
174
|
+
- test/generators/active_record_generator_test.rb
|
|
175
|
+
- test/generators/devise_generator_test.rb
|
|
176
|
+
- test/generators/install_generator_test.rb
|
|
177
|
+
- test/generators/mongoid_generator_test.rb
|
|
178
|
+
- test/generators/views_generator_test.rb
|
|
179
|
+
- test/indifferent_hash.rb
|
|
156
180
|
- test/integration/authenticatable_test.rb
|
|
157
181
|
- test/integration/confirmable_test.rb
|
|
158
182
|
- test/integration/database_authenticatable_test.rb
|
|
159
183
|
- test/integration/http_authenticatable_test.rb
|
|
160
184
|
- test/integration/lockable_test.rb
|
|
185
|
+
- test/integration/omniauthable_test.rb
|
|
161
186
|
- test/integration/recoverable_test.rb
|
|
162
187
|
- test/integration/registerable_test.rb
|
|
163
188
|
- test/integration/rememberable_test.rb
|
|
@@ -170,6 +195,7 @@ files:
|
|
|
170
195
|
- test/mapping_test.rb
|
|
171
196
|
- test/models/confirmable_test.rb
|
|
172
197
|
- test/models/database_authenticatable_test.rb
|
|
198
|
+
- test/models/encryptable_test.rb
|
|
173
199
|
- test/models/lockable_test.rb
|
|
174
200
|
- test/models/recoverable_test.rb
|
|
175
201
|
- test/models/rememberable_test.rb
|
|
@@ -178,24 +204,37 @@ files:
|
|
|
178
204
|
- test/models/trackable_test.rb
|
|
179
205
|
- test/models/validatable_test.rb
|
|
180
206
|
- test/models_test.rb
|
|
207
|
+
- test/omniauth/url_helpers_test.rb
|
|
181
208
|
- test/orm/active_record.rb
|
|
182
209
|
- test/orm/mongoid.rb
|
|
210
|
+
- test/rails_app/Rakefile
|
|
183
211
|
- test/rails_app/app/active_record/admin.rb
|
|
184
212
|
- test/rails_app/app/active_record/shim.rb
|
|
185
213
|
- test/rails_app/app/active_record/user.rb
|
|
214
|
+
- test/rails_app/app/controllers/admins/sessions_controller.rb
|
|
186
215
|
- test/rails_app/app/controllers/admins_controller.rb
|
|
187
216
|
- test/rails_app/app/controllers/application_controller.rb
|
|
188
217
|
- test/rails_app/app/controllers/home_controller.rb
|
|
189
218
|
- test/rails_app/app/controllers/publisher/registrations_controller.rb
|
|
190
219
|
- test/rails_app/app/controllers/publisher/sessions_controller.rb
|
|
191
|
-
- test/rails_app/app/controllers/
|
|
220
|
+
- test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb
|
|
192
221
|
- test/rails_app/app/controllers/users_controller.rb
|
|
193
222
|
- test/rails_app/app/helpers/application_helper.rb
|
|
194
223
|
- test/rails_app/app/mongoid/admin.rb
|
|
195
224
|
- test/rails_app/app/mongoid/shim.rb
|
|
196
225
|
- test/rails_app/app/mongoid/user.rb
|
|
226
|
+
- test/rails_app/app/views/admins/index.html.erb
|
|
227
|
+
- test/rails_app/app/views/admins/sessions/new.html.erb
|
|
228
|
+
- test/rails_app/app/views/home/index.html.erb
|
|
229
|
+
- test/rails_app/app/views/home/private.html.erb
|
|
230
|
+
- test/rails_app/app/views/layouts/application.html.erb
|
|
231
|
+
- test/rails_app/app/views/users/index.html.erb
|
|
232
|
+
- test/rails_app/app/views/users/mailer/confirmation_instructions.erb
|
|
233
|
+
- test/rails_app/app/views/users/sessions/new.html.erb
|
|
234
|
+
- test/rails_app/config.ru
|
|
197
235
|
- test/rails_app/config/application.rb
|
|
198
236
|
- test/rails_app/config/boot.rb
|
|
237
|
+
- test/rails_app/config/database.yml
|
|
199
238
|
- test/rails_app/config/environment.rb
|
|
200
239
|
- test/rails_app/config/environments/development.rb
|
|
201
240
|
- test/rails_app/config/environments/production.rb
|
|
@@ -207,11 +246,19 @@ files:
|
|
|
207
246
|
- test/rails_app/config/routes.rb
|
|
208
247
|
- test/rails_app/db/migrate/20100401102949_create_tables.rb
|
|
209
248
|
- test/rails_app/db/schema.rb
|
|
249
|
+
- test/rails_app/lib/shared_admin.rb
|
|
250
|
+
- test/rails_app/lib/shared_user.rb
|
|
251
|
+
- test/rails_app/public/404.html
|
|
252
|
+
- test/rails_app/public/422.html
|
|
253
|
+
- test/rails_app/public/500.html
|
|
254
|
+
- test/rails_app/public/favicon.ico
|
|
255
|
+
- test/rails_app/script/rails
|
|
210
256
|
- test/routes_test.rb
|
|
257
|
+
- test/schema_test.rb
|
|
211
258
|
- test/support/assertions.rb
|
|
212
259
|
- test/support/helpers.rb
|
|
213
260
|
- test/support/integration.rb
|
|
214
|
-
- test/support/
|
|
261
|
+
- test/support/locale/en.yml
|
|
215
262
|
- test/support/webrat/integrations/rails.rb
|
|
216
263
|
- test/test_helper.rb
|
|
217
264
|
- test/test_helpers_test.rb
|
|
@@ -220,8 +267,8 @@ homepage: http://github.com/plataformatec/devise
|
|
|
220
267
|
licenses: []
|
|
221
268
|
|
|
222
269
|
post_install_message:
|
|
223
|
-
rdoc_options:
|
|
224
|
-
|
|
270
|
+
rdoc_options: []
|
|
271
|
+
|
|
225
272
|
require_paths:
|
|
226
273
|
- lib
|
|
227
274
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
@@ -244,8 +291,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
244
291
|
version: "0"
|
|
245
292
|
requirements: []
|
|
246
293
|
|
|
247
|
-
rubyforge_project:
|
|
248
|
-
rubygems_version: 1.3
|
|
294
|
+
rubyforge_project: devise
|
|
295
|
+
rubygems_version: 1.5.3
|
|
249
296
|
signing_key:
|
|
250
297
|
specification_version: 3
|
|
251
298
|
summary: Flexible authentication solution for Rails with Warden
|
|
@@ -256,11 +303,18 @@ test_files:
|
|
|
256
303
|
- test/devise_test.rb
|
|
257
304
|
- test/encryptors_test.rb
|
|
258
305
|
- test/failure_app_test.rb
|
|
306
|
+
- test/generators/active_record_generator_test.rb
|
|
307
|
+
- test/generators/devise_generator_test.rb
|
|
308
|
+
- test/generators/install_generator_test.rb
|
|
309
|
+
- test/generators/mongoid_generator_test.rb
|
|
310
|
+
- test/generators/views_generator_test.rb
|
|
311
|
+
- test/indifferent_hash.rb
|
|
259
312
|
- test/integration/authenticatable_test.rb
|
|
260
313
|
- test/integration/confirmable_test.rb
|
|
261
314
|
- test/integration/database_authenticatable_test.rb
|
|
262
315
|
- test/integration/http_authenticatable_test.rb
|
|
263
316
|
- test/integration/lockable_test.rb
|
|
317
|
+
- test/integration/omniauthable_test.rb
|
|
264
318
|
- test/integration/recoverable_test.rb
|
|
265
319
|
- test/integration/registerable_test.rb
|
|
266
320
|
- test/integration/rememberable_test.rb
|
|
@@ -273,6 +327,7 @@ test_files:
|
|
|
273
327
|
- test/mapping_test.rb
|
|
274
328
|
- test/models/confirmable_test.rb
|
|
275
329
|
- test/models/database_authenticatable_test.rb
|
|
330
|
+
- test/models/encryptable_test.rb
|
|
276
331
|
- test/models/lockable_test.rb
|
|
277
332
|
- test/models/recoverable_test.rb
|
|
278
333
|
- test/models/rememberable_test.rb
|
|
@@ -281,24 +336,37 @@ test_files:
|
|
|
281
336
|
- test/models/trackable_test.rb
|
|
282
337
|
- test/models/validatable_test.rb
|
|
283
338
|
- test/models_test.rb
|
|
339
|
+
- test/omniauth/url_helpers_test.rb
|
|
284
340
|
- test/orm/active_record.rb
|
|
285
341
|
- test/orm/mongoid.rb
|
|
342
|
+
- test/rails_app/Rakefile
|
|
286
343
|
- test/rails_app/app/active_record/admin.rb
|
|
287
344
|
- test/rails_app/app/active_record/shim.rb
|
|
288
345
|
- test/rails_app/app/active_record/user.rb
|
|
346
|
+
- test/rails_app/app/controllers/admins/sessions_controller.rb
|
|
289
347
|
- test/rails_app/app/controllers/admins_controller.rb
|
|
290
348
|
- test/rails_app/app/controllers/application_controller.rb
|
|
291
349
|
- test/rails_app/app/controllers/home_controller.rb
|
|
292
350
|
- test/rails_app/app/controllers/publisher/registrations_controller.rb
|
|
293
351
|
- test/rails_app/app/controllers/publisher/sessions_controller.rb
|
|
294
|
-
- test/rails_app/app/controllers/
|
|
352
|
+
- test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb
|
|
295
353
|
- test/rails_app/app/controllers/users_controller.rb
|
|
296
354
|
- test/rails_app/app/helpers/application_helper.rb
|
|
297
355
|
- test/rails_app/app/mongoid/admin.rb
|
|
298
356
|
- test/rails_app/app/mongoid/shim.rb
|
|
299
357
|
- test/rails_app/app/mongoid/user.rb
|
|
358
|
+
- test/rails_app/app/views/admins/index.html.erb
|
|
359
|
+
- test/rails_app/app/views/admins/sessions/new.html.erb
|
|
360
|
+
- test/rails_app/app/views/home/index.html.erb
|
|
361
|
+
- test/rails_app/app/views/home/private.html.erb
|
|
362
|
+
- test/rails_app/app/views/layouts/application.html.erb
|
|
363
|
+
- test/rails_app/app/views/users/index.html.erb
|
|
364
|
+
- test/rails_app/app/views/users/mailer/confirmation_instructions.erb
|
|
365
|
+
- test/rails_app/app/views/users/sessions/new.html.erb
|
|
366
|
+
- test/rails_app/config.ru
|
|
300
367
|
- test/rails_app/config/application.rb
|
|
301
368
|
- test/rails_app/config/boot.rb
|
|
369
|
+
- test/rails_app/config/database.yml
|
|
302
370
|
- test/rails_app/config/environment.rb
|
|
303
371
|
- test/rails_app/config/environments/development.rb
|
|
304
372
|
- test/rails_app/config/environments/production.rb
|
|
@@ -310,11 +378,19 @@ test_files:
|
|
|
310
378
|
- test/rails_app/config/routes.rb
|
|
311
379
|
- test/rails_app/db/migrate/20100401102949_create_tables.rb
|
|
312
380
|
- test/rails_app/db/schema.rb
|
|
381
|
+
- test/rails_app/lib/shared_admin.rb
|
|
382
|
+
- test/rails_app/lib/shared_user.rb
|
|
383
|
+
- test/rails_app/public/404.html
|
|
384
|
+
- test/rails_app/public/422.html
|
|
385
|
+
- test/rails_app/public/500.html
|
|
386
|
+
- test/rails_app/public/favicon.ico
|
|
387
|
+
- test/rails_app/script/rails
|
|
313
388
|
- test/routes_test.rb
|
|
389
|
+
- test/schema_test.rb
|
|
314
390
|
- test/support/assertions.rb
|
|
315
391
|
- test/support/helpers.rb
|
|
316
392
|
- test/support/integration.rb
|
|
317
|
-
- test/support/
|
|
393
|
+
- test/support/locale/en.yml
|
|
318
394
|
- test/support/webrat/integrations/rails.rb
|
|
319
395
|
- test/test_helper.rb
|
|
320
396
|
- test/test_helpers_test.rb
|
data/TODO
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require "bcrypt"
|
|
2
|
-
|
|
3
|
-
module Devise
|
|
4
|
-
module Encryptors
|
|
5
|
-
# = BCrypt
|
|
6
|
-
# Uses the BCrypt hash algorithm to encrypt passwords.
|
|
7
|
-
class Bcrypt < Base
|
|
8
|
-
# Gererates a default password digest based on stretches, salt, pepper and the
|
|
9
|
-
# incoming password. We don't strech it ourselves since BCrypt does so internally.
|
|
10
|
-
def self.digest(password, stretches, salt, pepper)
|
|
11
|
-
::BCrypt::Engine.hash_secret([password, pepper].join, salt, stretches)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.salt(stretches)
|
|
15
|
-
::BCrypt::Engine.generate_salt(stretches)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|