Skip to content
Browse files

Fix: Don't create app if lookup returns anything but 403

  • Loading branch information...
1 parent 6de2afb commit 68b24ebd02cb2a847b36387840f3c94e408213fb Jesse Stuart committed Oct 4, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/omniauth/strategies/tent.rb
View
11 lib/omniauth/strategies/tent.rb
@@ -10,6 +10,7 @@ class Tent
Error = Class.new(StandardError)
AppCreateFailure = Class.new(Error)
+ AppLookupFailure = Class.new(Error)
AppAuthorizationCreateFailure = Class.new(Error)
StateMissmatchError = Class.new(Error)
@@ -39,6 +40,8 @@ def request_phase
end
rescue AppCreateFailure => e
fail!(:app_create_failure, e)
+ rescue AppLookupFailure => e
+ fail!(:app_lookup_failure, e)
rescue => e
fail!(:unknown_error, e)
end
@@ -90,7 +93,13 @@ def find_or_create_app!
:mac_algorithm => app[:mac_algorithm])
if 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)
else
create_app

0 comments on commit 68b24eb

Please sign in to comment.
Something went wrong with that request. Please try again.