Sha256: 24934079e4600d78ae8af53e78aa120457c570b029ca673435fc7cf622c13854

Contents?: true

Size: 979 Bytes

Versions: 3

Compression:

Stored size: 979 Bytes

Contents

# Injects behaviors into User model so that it will work with Hydra Access Controls
# By default, this module assumes you are using the User model created by Blacklight, which uses Devise.
# To integrate your own User implementation into Hydra, override this Module or define your own User model in app/models/user.rb within your Hydra head.
module Hydra::User
  extend ActiveSupport::Concern
  include Blacklight::AccessControls::User
  
  included do
    class_attribute :group_service
    self.group_service = RoleMapper
  end

  def groups
    group_service.fetch_groups(user: self)
  end
  
  module ClassMethods
    # This method finds User objects using the user_key as specified by the
    # Devise authentication_keys configuration variable. This method encapsulates
    # whether we use email or username (or something else) as the identifing user attribute.
    def find_by_user_key(key)
      find_by(Devise.authentication_keys.first.to_sym => key)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hydra-access-controls-10.4.0 lib/hydra/user.rb
hydra-access-controls-10.4.0.rc2 lib/hydra/user.rb
hydra-access-controls-10.4.0.rc1 lib/hydra/user.rb