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

Commit

Permalink
Fix: Don't create app if lookup returns anything but 403
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Stuart committed Oct 4, 2012
1 parent 6de2afb commit 68b24eb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/omniauth/strategies/tent.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Tent


Error = Class.new(StandardError) Error = Class.new(StandardError)
AppCreateFailure = Class.new(Error) AppCreateFailure = Class.new(Error)
AppLookupFailure = Class.new(Error)
AppAuthorizationCreateFailure = Class.new(Error) AppAuthorizationCreateFailure = Class.new(Error)
StateMissmatchError = Class.new(Error) StateMissmatchError = Class.new(Error)


Expand Down Expand Up @@ -39,6 +40,8 @@ def request_phase
end end
rescue AppCreateFailure => e rescue AppCreateFailure => e
fail!(:app_create_failure, e) fail!(:app_create_failure, e)
rescue AppLookupFailure => e
fail!(:app_lookup_failure, e)
rescue => e rescue => e
fail!(:unknown_error, e) fail!(:unknown_error, e)
end end
Expand Down Expand Up @@ -90,7 +93,13 @@ def find_or_create_app!
:mac_algorithm => app[:mac_algorithm]) :mac_algorithm => app[:mac_algorithm])
if app[:id] if app[:id]
res = client.app.get(app[:id]) res = client.app.get(app[:id])
return create_app if res.body.kind_of?(::String) if res.body.kind_of?(::String)
if res.status == 403
create_app and return
else
raise AppLookupFailure.new(res.inspect)
end
end
set_app(app) set_app(app)
else else
create_app create_app
Expand Down

0 comments on commit 68b24eb

Please sign in to comment.