lib/opro/controllers/application_controller_helper.rb in opro-0.0.1 vs lib/opro/controllers/application_controller_helper.rb in opro-0.0.2
- old
+ new
@@ -13,10 +13,11 @@
skip_before_filter :verify_authenticity_token, :if => :valid_oauth?
end
def opro_authenticate_user!
Opro.authenticate_user_method.call(self)
+ true
end
module ClassMethods
def allow_oauth!(options = {})
prepend_before_filter :allow_oauth, options
@@ -35,13 +36,17 @@
@use_oauth ||= false
end
# returns boolean if oauth request
def valid_oauth?
- oauth? && oauth_user.present? && oauth_client_has_permissions?
+ oauth? && oauth_user.present? && oauth_client_not_expired? && oauth_client_has_permissions?
end
+ def oauth_client_not_expired?
+ oauth_access_grant.not_expired?
+ end
+
def disallow_oauth
@use_oauth = false
end
def allow_oauth
@@ -51,10 +56,10 @@
def oauth?
allow_oauth? && params[:access_token].present?
end
def oauth_access_grant
- @oauth_access_grant ||= Oauth::AccessGrant.find_for_token(params[:access_token])
+ @oauth_access_grant ||= Oauth::AuthGrant.find_for_token(params[:access_token])
end
def oauth_client_app
@oauth_client_app ||= oauth_access_grant.client_application
end