Module: Hancock::Client::Helpers::Rack
- Defined in:
- lib/hancock-client/helpers/rack.rb
Instance Method Summary collapse
- #absolute_url(suffix = nil) ⇒ Object
- #excluded_path? ⇒ Boolean
- #sso_logged_in? ⇒ Boolean
- #sso_login_as(user_id, sreg_params) ⇒ Object
- #sso_user_email ⇒ Object
- #sso_user_first_name ⇒ Object
- #sso_user_full_name ⇒ Object
- #sso_user_id ⇒ Object
- #sso_user_last_name ⇒ Object
Instance Method Details
#absolute_url(suffix = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/hancock-client/helpers/rack.rb', line 39 def absolute_url(suffix = nil) port_part = case request.scheme when "http" request.port == 80 ? "" : ":#{request.port}" when "https" request.port == 443 ? "" : ":#{request.port}" end "#{request.scheme}://#{request.host}#{port_part}#{suffix}" end |
#excluded_path? ⇒ Boolean
49 50 51 |
# File 'lib/hancock-client/helpers/rack.rb', line 49 def excluded_path? .exclude_paths && .exclude_paths.include?(request.path_info) end |
#sso_logged_in? ⇒ Boolean
5 6 7 |
# File 'lib/hancock-client/helpers/rack.rb', line 5 def sso_logged_in? session[:sso] && sso_user_id end |
#sso_login_as(user_id, sreg_params) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/hancock-client/helpers/rack.rb', line 9 def sso_login_as(user_id, sreg_params) session.delete(:last_oidreq) session.delete('OpenID::Consumer::last_requested_endpoint') session.delete('OpenID::Consumer::DiscoveredServices::OpenID::Consumer::') session[:sso] ||= { } session[:sso][:user_id] = user_id sreg_params.each { |key, value| session[:sso][key.to_sym] = value.to_s } end |
#sso_user_email ⇒ Object
23 24 25 |
# File 'lib/hancock-client/helpers/rack.rb', line 23 def sso_user_email session[:sso][:email] end |
#sso_user_first_name ⇒ Object
27 28 29 |
# File 'lib/hancock-client/helpers/rack.rb', line 27 def sso_user_first_name session[:sso][:first_name] end |
#sso_user_full_name ⇒ Object
35 36 37 |
# File 'lib/hancock-client/helpers/rack.rb', line 35 def sso_user_full_name "#{session[:sso][:first_name]} #{session[:sso][:last_name]}" end |
#sso_user_id ⇒ Object
19 20 21 |
# File 'lib/hancock-client/helpers/rack.rb', line 19 def sso_user_id session[:sso][:user_id] end |
#sso_user_last_name ⇒ Object
31 32 33 |
# File 'lib/hancock-client/helpers/rack.rb', line 31 def sso_user_last_name session[:sso][:last_name] end |