Sha256: 53c2315b5f2df8e46e7a5806f8e999f455339bfefdd05e0fa2170f2fd74ed83d

Contents?: true

Size: 649 Bytes

Versions: 19

Compression:

Stored size: 649 Bytes

Contents

class OauthToken < ActiveRecord::Base
  belongs_to :client_application
  belongs_to :user
  validates_uniqueness_of :token
  validates_presence_of :client_application, :token
  before_validation :generate_keys, :on => :create

  def invalidated?
    invalidated_at != nil
  end

  def invalidate!
    update_attribute(:invalidated_at, Time.now)
  end

  def authorized?
    authorized_at != nil && !invalidated?
  end

  def to_query
    "oauth_token=#{token}&oauth_token_secret=#{secret}"
  end

  protected

  def generate_keys
    self.token = OAuth::Helper.generate_key(40)[0,40]
    self.secret = OAuth::Helper.generate_key(40)[0,40]
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
houston-oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
panjiva-oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.5.1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.5.0 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-provider-0.5.0rc1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.rc2 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.rc1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre7 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre6 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre5 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
insrc-oauth-plugin-0.4.0.pre6 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
insrc-oauth-plugin-0.4.0.pre5 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
le1t0-oauth-plugin-0.4.0.pre4.001 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre4 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre3 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre2 lib/generators/active_record/oauth_provider_templates/oauth_token.rb
oauth-plugin-0.4.0.pre1 lib/generators/active_record/oauth_provider_templates/oauth_token.rb