app/models/user.rb
# frozen_string_literal: true
class User < ApplicationRecord
# Connects this user object to Hydra behaviors.
include Hydra::User
# Connects this user object to Hyrax behaviors.
include Hyrax::User
include Hyrax::UserUsageStats
if Blacklight::Utils.needs_attr_accessible?
attr_accessible :email, :password, :password_confirmation
end
# Connects this user object to Blacklights Bookmarks.
include Blacklight::User
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, omniauth_providers: [:shibboleth]
def self.from_omniauth(auth)
where(email: auth.uid).first_or_create do |user|
user.email = auth.uid
user.display_name = auth.info.name
user.password = Devise.friendly_token[0, 20]
end
end
# Method added by Blacklight; Blacklight uses #to_s on your
# user class to get a user-displayable login/identifier for
# the account.
def to_s
email
end
end