mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
after_sign_in_path_for always receives a resource
This commit is contained in:
parent
81c49c69df
commit
731650a0f1
4 changed files with 14 additions and 9 deletions
12
Gemfile.lock
12
Gemfile.lock
|
@ -22,9 +22,9 @@ PATH
|
|||
erubis (~> 2.6.6)
|
||||
i18n (~> 0.4.1)
|
||||
rack (~> 1.2.1)
|
||||
rack-mount (~> 0.6.9)
|
||||
rack-mount (~> 0.6.10)
|
||||
rack-test (~> 0.5.4)
|
||||
tzinfo (~> 0.3.22)
|
||||
tzinfo (~> 0.3.23)
|
||||
activemodel (3.0.0.rc)
|
||||
activesupport (= 3.0.0.rc)
|
||||
builder (~> 2.1.2)
|
||||
|
@ -33,7 +33,7 @@ PATH
|
|||
activemodel (= 3.0.0.rc)
|
||||
activesupport (= 3.0.0.rc)
|
||||
arel (~> 0.4.0)
|
||||
tzinfo (~> 0.3.22)
|
||||
tzinfo (~> 0.3.23)
|
||||
activeresource (3.0.0.rc)
|
||||
activemodel (= 3.0.0.rc)
|
||||
activesupport (= 3.0.0.rc)
|
||||
|
@ -44,7 +44,7 @@ PATH
|
|||
activerecord (= 3.0.0.rc)
|
||||
activeresource (= 3.0.0.rc)
|
||||
activesupport (= 3.0.0.rc)
|
||||
bundler (>= 1.0.0.rc.1)
|
||||
bundler (>= 1.0.0.rc.2)
|
||||
railties (= 3.0.0.rc)
|
||||
railties (3.0.0.rc)
|
||||
actionpack (= 3.0.0.rc)
|
||||
|
@ -94,7 +94,7 @@ GEM
|
|||
multi_json (>= 0.0.4)
|
||||
polyglot (0.3.1)
|
||||
rack (1.2.1)
|
||||
rack-mount (0.6.9)
|
||||
rack-mount (0.6.12)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (0.5.4)
|
||||
rack (>= 1.0)
|
||||
|
@ -108,7 +108,7 @@ GEM
|
|||
thor (0.14.0)
|
||||
treetop (1.4.8)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.22)
|
||||
tzinfo (0.3.23)
|
||||
warden (0.10.7)
|
||||
rack (>= 1.0.0)
|
||||
weakling (0.0.4-java)
|
||||
|
|
5
Rakefile
5
Rakefile
|
@ -36,6 +36,7 @@ end
|
|||
begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |s|
|
||||
root_files = FileList["README.rdoc", "MIT-LICENSE", "CHANGELOG.rdoc"]
|
||||
s.name = "devise"
|
||||
s.version = Devise::VERSION.dup
|
||||
s.summary = "Flexible authentication solution for Rails with Warden"
|
||||
|
@ -43,8 +44,8 @@ begin
|
|||
s.homepage = "http://github.com/plataformatec/devise"
|
||||
s.description = "Flexible authentication solution for Rails with Warden"
|
||||
s.authors = ['José Valim', 'Carlos Antônio']
|
||||
s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
|
||||
s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
|
||||
s.files = root_files + FileList["{app,config,lib}/**/*"]
|
||||
s.extra_rdoc_files = root_files
|
||||
s.add_dependency("warden", "~> 0.10.7")
|
||||
s.add_dependency("bcrypt-ruby", "~> 2.1.2")
|
||||
end
|
||||
|
|
|
@ -78,7 +78,10 @@ module Devise
|
|||
# Example:
|
||||
# before_filter :require_no_authentication, :only => :new
|
||||
def require_no_authentication
|
||||
redirect_to after_sign_in_path_for(resource_name) if warden.authenticated?(resource_name)
|
||||
if warden.authenticated?(resource_name)
|
||||
resource = warden.user(resource_name)
|
||||
redirect_to after_sign_in_path_for(resource)
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the flash message with :key, using I18n. By default you are able
|
||||
|
|
|
@ -40,6 +40,7 @@ class HelpersTest < ActionController::TestCase
|
|||
|
||||
test 'require no authentication tests current mapping' do
|
||||
@mock_warden.expects(:authenticated?).with(:user).returns(true)
|
||||
@mock_warden.expects(:user).with(:user).returns(User.new)
|
||||
@controller.expects(:redirect_to).with(root_path)
|
||||
@controller.send :require_no_authentication
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue