Permalink
Browse files

Moved renders into methods for easier overriding

  • Loading branch information...
1 parent 44e04f2 commit 51eff441155d01b76d0ac4fd784299148ded57a0 @AndrewO AndrewO committed Dec 30, 2010
Showing with 15 additions and 6 deletions.
  1. +15 −6 lib/classy_cas.rb
View
@@ -9,6 +9,7 @@
require 'rack-flash'
require 'backports'
require 'system_timer'
+require 'warden'
require 'addressable/uri'
@@ -55,7 +56,7 @@ class Server < Sinatra::Base
if @renew
@login_ticket = LoginTicket.create!(settings.redis)
- erb :login
+ render_login
elsif @gateway
if @service_url
if sso_session
@@ -73,7 +74,7 @@ class Server < Sinatra::Base
end
else
@login_ticket = LoginTicket.create!(settings.redis)
- erb :login
+ render_login
end
else
if sso_session
@@ -88,11 +89,11 @@ class Server < Sinatra::Base
end
redirect redirect_url.to_s, 303
else
- erb :logged_in
+ render_logged_in
end
else
@login_ticket = LoginTicket.create!(settings.redis)
- erb :login
+ render_login
end
end
end
@@ -120,7 +121,7 @@ class Server < Sinatra::Base
st.save!(settings.redis)
redirect service_url + "?ticket=#{st.ticket}", 303
else
- erb :logged_in
+ render_login
end
end
@@ -165,15 +166,23 @@ class Server < Sinatra::Base
end
@login_ticket = LoginTicket.create!(settings.redis)
@logout = true
- erb :login
+ render_login
end
post "/unauthenticated" do
@login_ticket = LoginTicket.create!(settings.redis)
flash[:error] = "Login was not successful"
+ render_login
+ end
+
+ def render_login
erb :login
end
+ def render_logged_in
+ erb :logged_in
+ end
+
private
def warden
request.env["warden"]

0 comments on commit 51eff44

Please sign in to comment.