Module: Passport::Oauth::Process::ClassMethods

Defined in:
lib/passport/oauth/protocol/process.rb

Instance Method Summary collapse

Instance Method Details

#approve(record) ⇒ Object Also known as: complete



27
28
29
30
31
32
33
# File 'lib/passport/oauth/protocol/process.rb', line 27

def approve(record)
  return nil if !complete?
  restore(record) if record
  token = find_or_create_token
  clear
  token
end

#clearObject

Step last, after the response having lots of trouble testing logging and out multiple times, so there needs to be a solid way to know when a user has messed up loggin in.



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/passport/oauth/protocol/process.rb', line 39

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

#process(record = nil) ⇒ Object Also known as: start



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/passport/oauth/protocol/process.rb', line 10

def process(record = nil)
  authorize_hash = token_class.authorize(callback_url)
  
  session[:oauth_request_token]        = authorize_hash[:token]
  session[:oauth_request_token_secret] = authorize_hash[:secret]
  session[:auth_request_class]         = record.class.name if record
  session[:authentication_type]        = params["authentication_type"]
  session[:oauth_provider]             = params["oauth_provider"]
  session[:auth_method]                = "oauth"
  session[:auth_callback_method]       = "post"# controller.request.method

  store(record) if record
  
  redirect authorize_hash[:url]
end