Sha256: 4c65bb550d0ce2cad994d8999f2e4dfb7146550e65dbe2903b10bb1d4fbbc277

Contents?: true

Size: 653 Bytes

Versions: 16

Compression:

Stored size: 653 Bytes

Contents

class Identity < ActiveRecord::Base
  belongs_to :user
  validates_presence_of :uid, :provider
  validates_uniqueness_of :uid, :scope => :provider

  def self.find_for_oauth(auth)
    identity = find_by(provider: auth.provider, uid: auth.uid)
    identity = create(uid: auth.uid, provider: auth.provider) if identity.nil?
    identity.accesstoken = auth.credentials.token
    identity.name = auth.info.name
    identity.email = auth.info.email
    identity.nickname = auth.info.nickname
    identity.image = auth.info.image
    identity.phone = auth.info.phone
    identity.urls = (auth.info.urls || "").to_json
    identity.save
    identity
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
happy_seed-0.0.19 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.18 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.17 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.16 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.15 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.14 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.13 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.12 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.11 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.10 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.9 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.8 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.7 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.6 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.5 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb
happy_seed-0.0.4 lib/generators/happy_seed/omniauth/templates/app/models/identity.rb