Sha256: 1bc07e8a33af668c49cfef6017897ee5426832d5b7fc509be1b7a529cfdb90f6

Contents?: true

Size: 699 Bytes

Versions: 5

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

module SolidusSocial
  module Spree
    module UserDecorator
      def self.prepended(base)
        base.class_eval do
          has_many :user_authentications, dependent: :destroy

          devise :omniauthable
        end
      end

      def apply_omniauth(omniauth)
        if omniauth.fetch('info', {})['email'].present?
          self.email = omniauth['info']['email'] if email.blank?
        end
        user_authentications.build(provider: omniauth['provider'], uid: omniauth['uid'])
      end

      def password_required?
        (user_authentications.empty? || password.present?) && super
      end

      ::Spree.user_class.prepend self
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_social-1.6.0 app/decorators/models/solidus_social/spree/user_decorator.rb
solidus_social-1.5.0 app/decorators/models/solidus_social/spree/user_decorator.rb
solidus_social-1.4.0 app/decorators/models/solidus_social/spree/user_decorator.rb
solidus_social-1.3.1 app/decorators/models/solidus_social/spree/user_decorator.rb
solidus_social-1.3.0 app/decorators/models/solidus_social/spree/user_decorator.rb