Sha256: 35394fdf1fc9c1d8d825ea5eeae21d334fdd058f5281fbbc948807a31410e685

Contents?: true

Size: 694 Bytes

Versions: 8

Compression:

Stored size: 694 Bytes

Contents

# include MuckAuth::Models::MuckUser
module MuckAuth
  module Models
    module MuckUser
      extend ActiveSupport::Concern
    
      included do
        has_many :authentications, :as => :authenticatable, :dependent => :destroy
        accepts_nested_attributes_for :authentications, :allow_destroy => true
      end
      
      def apply_omniauth(omniauth)
        self.email = omniauth['user_info']['email'] if email.blank?
        authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'], :raw_auth => omniauth.to_json)
      end
      
      def password_required?
        (authentications.empty? || !password.blank?) && super
      end
      
    end 
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
muck-auth-3.3.3 lib/muck-auth/models/user.rb
muck-auth-3.3.2 lib/muck-auth/models/user.rb
muck-auth-3.3.1 lib/muck-auth/models/user.rb
muck-auth-3.3.0 lib/muck-auth/models/user.rb
muck-auth-3.2.3 lib/muck-auth/models/user.rb
muck-auth-3.2.2 lib/muck-auth/models/user.rb
muck-auth-3.2.1 lib/muck-auth/models/user.rb
muck-auth-3.2.0 lib/muck-auth/models/user.rb