Sha256: 9622aabb229e319309673df144e4b5499919249e6cfe6ad1bfaaabff59d4f6ce
Contents?: true
Size: 1.23 KB
Versions: 8
Compression:
Stored size: 1.23 KB
Contents
# coding: utf-8 module DeviseRussian module Models module Base def self.included(base) base.extend ClassMethods end module ClassMethods def omniauthable has_many :authentications, :dependent => :destroy def omniauth_enabled true end unless included_modules.include? InstanceMethods include InstanceMethods end end end module InstanceMethods def apply_omniauth(omniauth, with_self=false) provider = omniauth['provider'] uid = omniauth['uid'] user_email = omniauth['extra']['raw_info']['email'] rescue nil user_name = omniauth['extra']['raw_info']['first_name'] rescue nil if with_self self.email = user_email if user_email && self.email.blank? self.name = user_name if user_name && self.name.blank? end self.authentications.new( :provider => provider, :uid => uid, :email => user_email, :name => user_name ) end def password_required? (authentications.empty? || !password.blank?) && super end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems