Module: Hancock::Client::Helpers::Rack

Defined in:
lib/hancock-client/helpers/rack.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


49
50
51
# File 'lib/hancock-client/helpers/rack.rb', line 49

def excluded_path?
  options.exclude_paths && options.exclude_paths.include?(request.path_info)
end

#sso_logged_in?Boolean

Returns:

  • (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 (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_emailObject



23
24
25
# File 'lib/hancock-client/helpers/rack.rb', line 23

def sso_user_email
  session[:sso][:email]
end

#sso_user_first_nameObject



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_nameObject



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_idObject



19
20
21
# File 'lib/hancock-client/helpers/rack.rb', line 19

def sso_user_id
  session[:sso][:user_id]
end

#sso_user_last_nameObject



31
32
33
# File 'lib/hancock-client/helpers/rack.rb', line 31

def sso_user_last_name
  session[:sso][:last_name]
end