Merge pull request #1258 from wildchild/master
Don't require explicit scope in authenticate router extension
This commit is contained in:
commit
31e4ef5e4b
|
@ -205,11 +205,15 @@ module ActionDispatch::Routing
|
||||||
|
|
||||||
# Allow you to add authentication request from the router:
|
# Allow you to add authentication request from the router:
|
||||||
#
|
#
|
||||||
# authenticate(:user) do
|
# authenticate do
|
||||||
# resources :post
|
# resources :post
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
def authenticate(scope)
|
# authenticate(:admin) do
|
||||||
|
# resources :users
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
def authenticate(scope=nil)
|
||||||
constraint = lambda do |request|
|
constraint = lambda do |request|
|
||||||
request.env["warden"].authenticate!(:scope => scope)
|
request.env["warden"].authenticate!(:scope => scope)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ Rails.application.routes.draw do
|
||||||
get :expire, :on => :member
|
get :expire, :on => :member
|
||||||
get :accept, :on => :member
|
get :accept, :on => :member
|
||||||
|
|
||||||
authenticate :user do
|
authenticate do
|
||||||
post :exhibit, :on => :member
|
post :exhibit, :on => :member
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue