<commit_before>class User < ActiveRecord::Base
  # Connects this user object to Hydra behaviors. 
  include Hydra::User
 
  # Connects this user object to Role-management behaviors. 
  include Hydra::RoleManagement::UserRoles

  # Connects this user object to Blacklights Bookmarks. 
  include Blacklight::User

  # Include default devise modules. Others available are:
  # :database_authenticatable,
  # :recoverable, :rememberable, :trackable, :validatable,
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :omniauthable, :registerable, :omniauth_providers => [:google_oauth2]

  validates :email, :phone_number, presence: true
  validates :email, uniqueness: true

  # 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
    name.nil? ? email : name
  end

  def is?(role)
    self.roles.include?(role.to_s)
  end

  # Guest users are disabled in this application.  The default Blacklight installation includes the gem devise-guests
  # which is not bundled with this app.  hydra-roles-management gem requires a guest boolean, so we must provide it here.
  def guest?
    false
  end

  def self.find_for_google_oauth2(access_token, signed_in_resource=nil)
    data = access_token.info
    user = User.where(:email => data["email"]).first

    unless user
      # Return a new user rather than create one since Users should not be able to create their own accounts.
      user = User.new
    end
    user
  end
end<commit_msg>Fix logic error in determining User's role<commit_after>class User < ActiveRecord::Base
  # Connects this user object to Hydra behaviors. 
  include Hydra::User
 
  # Connects this user object to Role-management behaviors. 
  include Hydra::RoleManagement::UserRoles

  # Connects this user object to Blacklights Bookmarks. 
  include Blacklight::User

  # Include default devise modules. Others available are:
  # :database_authenticatable,
  # :recoverable, :rememberable, :trackable, :validatable,
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  devise :omniauthable, :registerable, :omniauth_providers => [:google_oauth2]

  validates :email, :phone_number, presence: true
  validates :email, uniqueness: true

  # 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
    name.nil? ? email : name
  end

  def is?(role)
    self.roles.pluck(:name).include?(role.to_s)
  end

  # Guest users are disabled in this application.  The default Blacklight installation includes the gem devise-guests
  # which is not bundled with this app.  hydra-roles-management gem requires a guest boolean, so we must provide it here.
  def guest?
    false
  end

  def self.find_for_google_oauth2(access_token, signed_in_resource=nil)
    data = access_token.info
    user = User.where(:email => data["email"]).first

    unless user
      # Return a new user rather than create one since Users should not be able to create their own accounts.
      user = User.new
    end
    user
  end
end
{'fraction_non_alphanumeric': 0.07554858934169278, 'fraction_numerical': 0.0012539184952978057, 'mean_word_length': 3.879204892966361, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3554335', 'n_tokens_mistral': 976, 'n_tokens_neox': 920, 'n_words': 333}