Navigation Menu

Skip to content

Commit

Permalink
add an implicit before filter so you don't have to in your framework
Browse files Browse the repository at this point in the history
  • Loading branch information
atmos committed Mar 24, 2009
1 parent f857b4a commit d47d6ec
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/sinatra/hancock/sso.rb
Expand Up @@ -21,7 +21,11 @@ def self.registered(app)
app.helpers Hancock::SSO::Helpers
app.enable :sessions
app.disable :raise_errors
# app.before { ensure_sso_authenticated unless request.path_info =~ %r!^/sso/log(in|out)! }
app.before do
unless request.path_info == '/sso/login'
throw(:halt, [302, {'Location' => '/sso/login'}, '']) unless session[:user_id]
end
end

app.get '/sso/login' do
if contact_id = params['id']
Expand Down
1 change: 0 additions & 1 deletion spec/client.rb
Expand Up @@ -5,7 +5,6 @@ module Spec
class Client < ::Hancock::Client::Default
set :environment, :development
get '/' do
redirect '/sso/login' unless session[:user_id]
haml(<<-HAML
%table
%thead
Expand Down
2 changes: 1 addition & 1 deletion spec/hancock_sinatra_spec.rb
Expand Up @@ -8,6 +8,6 @@
it "should greet the user when authenticated" do
pending
get '/'
last_response.body.should have_selector('p')
last_response.should have_selector('p')
end
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -26,6 +26,4 @@ def app
run Hancock::Spec::Client
end
end
#config.before(:each) do
#end
end

0 comments on commit d47d6ec

Please sign in to comment.