Sha256: 417ec2edfd670016b49ba504134d79f5eefca212884ef55b48be7e247677c829

Contents?: true

Size: 487 Bytes

Versions: 2

Compression:

Stored size: 487 Bytes

Contents

User.class_eval do
  has_many :user_authentications

  # Associates user to auth source
  def associate_auth(source)
    return if user_authentications.where(:provider => source['provider'], :uid => source['uid'].to_s).count > 0
    self.user_authentications.create!(:provider => source['provider'], :uid => source['uid'], :nickname => source["user_info"]['nickname'])
  end

  # Thx Ryan
  def password_required?
    (user_authentications.empty? || !password.blank?) && super
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_social-1.0.2 app/models/user_decorator.rb
spree_social-1.0.1 app/models/user_decorator.rb