Sha256: 1ab8b55efb7714eebc4f38c5c3bf64a196efeeb1143f01f7f645edb6f0867690

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

module Models::Users
  class Authentication < ActiveRecord::Base
    self.table_name = :restpack_user_authentications

    attr_accessible :application_id, :oauth, :provider, :uid, :user_id, :omniauth
    serialize :oauth, JSON

    validates_presence_of :application_id, :omniauth, :provider, :uid, :user_id
    validates :provider, :length => { :maximum => 128 }
    validates :uid, :length => { :maximum => 1024 }

    belongs_to :user

    def self.from_omniauth(application_id, omniauth)
      Authentication.new(
        application_id: application_id,
        provider: omniauth['provider'],
        uid: omniauth['uid'],
        omniauth: omniauth
      )
    end

    def self.get_by_omniauth(application_id, omniauth)
      Authentication.where(
        application_id: application_id,
        provider: omniauth['provider'],
        uid: omniauth['uid']
      ).first
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_user_service-0.0.5 lib/restpack_user_service/models/authentication.rb