Module: Passport::Context::ClassMethods

Defined in:
lib/passport/core/context.rb

Instance Method Summary collapse

Instance Method Details

#authentication_methodObject



44
45
46
# File 'lib/passport/core/context.rb', line 44

def authentication_method
  find(:authentication_method)
end

#authentication_typeObject

if we’ve said it’s a “user” (registration), or a “session” (login)



40
41
42
# File 'lib/passport/core/context.rb', line 40

def authentication_type
  find(:authentication_type)
end

#clearObject



48
49
50
51
52
53
54
55
56
# File 'lib/passport/core/context.rb', line 48

def clear
  [:auth_request_class,
    :authentication_type,
    :auth_method,
    :auth_attributes,
    :oauth_provider,
    :auth_callback_method
  ].each { |key| Rack::Context.delete_session_key(key) }
end

#debugObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/passport/core/context.rb', line 58

def debug
  puts "=== BEGIN DEBUG ==="
  puts "Passport.process? #{Passport.process?}"
  puts "Passport.approve? #{Passport.approve?}"
  puts "Passport::Oauth::Protocol.request? #{Passport::Oauth::Protocol.request?.inspect}"
  puts "Passport::Oauth::Protocol.params? #{Passport::Oauth::Protocol.params?.inspect}"
  puts "Passport::Oauth::Protocol.provider? #{Passport::Oauth::Protocol.provider?.inspect}"
  puts "Passport::Oauth::Protocol.response? #{Passport::Oauth::Protocol.response?.inspect}"
  puts "Passport::Oauth::Protocol.session? #{Passport::Oauth::Protocol.session?.inspect}"
  puts "Passport::Oauth::Protocol.token? #{Passport::Oauth::Protocol.token?.inspect}"
  puts "Session #{session.inspect}"
  puts "Params #{params.inspect}"
  puts "=== END DEBUG ==="
end

#find(key) ⇒ Object



8
9
10
# File 'lib/passport/core/context.rb', line 8

def find(key)
  Rack::Context.find(key)
end

#paramsObject



20
21
22
# File 'lib/passport/core/context.rb', line 20

def params
  Rack::Context.params
end

#params_key(key) ⇒ Object



24
25
26
# File 'lib/passport/core/context.rb', line 24

def params_key(key)
  Rack::Context.params_key(key)
end

#redirect(url) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/passport/core/context.rb', line 28

def redirect(url)
  if controller = Thread.current[:rails_context]
    controller.redirect_to(url)
  else
    puts "REDIRECT #{url}"
    response = Rack::Response.new
    response.redirect(url)
    response.finish
  end
end

#sessionObject



12
13
14
# File 'lib/passport/core/context.rb', line 12

def session
  Rack::Context.session
end

#session_key(key) ⇒ Object



16
17
18
# File 'lib/passport/core/context.rb', line 16

def session_key(key)
  Rack::Context.session_key(key)
end