Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b628729d1b
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (30 sloc) 0.84 kb
module Omnisocial
class LoginAccount < ActiveRecord::Base
belongs_to :user, :class_name => '::User'
serialize :user_hash
default_scope :include => :user
before_save do
self.login = self.remote_account_id if self.login.blank?
end
def self.find_or_create_from_auth_hash(auth_hash)
if (account = find_by_remote_account_id(auth_hash['uid']))
account.assign_account_info(auth_hash)
account.save
account
else
create_from_auth_hash(auth_hash)
end
end
def self.create_from_auth_hash(auth_hash)
create do |account|
account.assign_account_info(auth_hash)
end
end
def find_or_create_user
return self.user if self.user
::User.create do |user|
user.login_accounts << self
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.