lib/oauth/controllers/application_controller_methods.rb in oauth-plugin-0.4.1 vs lib/oauth/controllers/application_controller_methods.rb in oauth-plugin-0.5.0
- old
+ new
@@ -26,11 +26,11 @@
}.merge(options)
@strategies = Array(@options[:strategies])
@strategies << :interactive if @options[:interactive]
end
- def filter(controller)
+ def before(controller)
Authenticator.new(controller,@strategies).allow?
end
end
class Authenticator
@@ -42,12 +42,16 @@
def allow?
if @strategies.include?(:interactive) && interactive
true
elsif !(@strategies & env["oauth.strategies"].to_a).empty?
- @controller.send :current_user=, token.user if token
- true
+ if token.present?
+ @controller.send :current_user=, token.user
+ true
+ else
+ false
+ end
else
if @strategies.include?(:interactive)
controller.send :access_denied
else
controller.send :invalid_oauth_response
@@ -131,6 +135,6 @@
head 401
end
end
end
-end
\ No newline at end of file
+end