pelle / oauth-plugin

Rails plugin for OAuth
http://stakeventures.com/articles/2009/07/21/consuming-oauth-intelligently-in-rails
MIT License
717 stars 217 forks source link

Trouble with Mongoid #142

Open kpgarrod opened 10 years ago

kpgarrod commented 10 years ago

I had problems getting the plugin to work with Mongoid out of the box.

I had to override OauthConsumersController#load_consumer with this:

def load_consumer
    throw RecordNotFound unless OAUTH_CREDENTIALS.include?(consumer_key)
    deny_access! unless logged_in? || consumer_credentials[:allow_login]
    @consumer="#{consumer_key.to_s.camelcase}Token".constantize
    @token=current_user.consumer_tokens.where(type: @consumer).first if logged_in?
  end

It seems to me that this should work with ActiveRecord just as well as the original code, but I haven't tested it.