Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.

Commit

Permalink
Add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Stuart committed Oct 3, 2012
1 parent de35830 commit 233cc3c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/omniauth/strategies/tent.rb
Expand Up @@ -62,11 +62,14 @@ def perform_discovery!
end end


def find_or_create_app! def find_or_create_app!
puts 'find_or_create_app!'
app = Hashie::Mash.new(options[:get_app].call(get_state(:entity)) || {}) app = Hashie::Mash.new(options[:get_app].call(get_state(:entity)) || {})
puts "find_or_create_app! - app[:id] => #{app[:id].inspect}"
app[:id] ? set_app(app) : create_app app[:id] ? set_app(app) : create_app
end end


def set_app(app) def set_app(app)
puts "set_app: #{app.inspect}"
set_state(:app, app) set_state(:app, app)
end end


Expand All @@ -76,18 +79,23 @@ def get_app


def create_app def create_app
client = ::TentClient.new(@server_url) client = ::TentClient.new(@server_url)
res = client.app.create( app_attrs = {
:name => options.app.name, :name => options.app.name,
:description => options.app.description, :description => options.app.description,
:scopes => options.app.scopes, :scopes => options.app.scopes,
:icon => options.app.icon, :icon => options.app.icon,
:url => options.app.url, :url => options.app.url,
:redirect_uris => options.app.redirect_uris || [callback_url] :redirect_uris => options.app.redirect_uris || [callback_url]
) }
puts "create_app - app_attrs => #{app_attrs.inspect}"

res = client.app.create(app_attrs)


puts "create_app - app => #{res.inspect}"
if (app = res.body) && !app.kind_of?(::String) if (app = res.body) && !app.kind_of?(::String)
set_app(app) set_app(app)
else else
puts "create_app - fail!"
fail!(:app_create_failure, AppCreateFailure.new(res.body)) fail!(:app_create_failure, AppCreateFailure.new(res.body))
end end
end end
Expand Down

0 comments on commit 233cc3c

Please sign in to comment.