<commit_before>class Admin < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :registerable, :lockable, :timeoutable and :omniauthable
  devise :token_authenticatable, :database_authenticatable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
  attr_accessible :role_ids

  before_save :ensure_authentication_token

  has_many :assignments, dependent: :destroy
  has_many :roles, through: :assignments
end
<commit_msg>Add validation for role for new users. Note: there is still a bug when a user doesn't have a role assigned, which results in an infinite loop when they log in. This is because the root_url is /validations, which is limited to project_participants and above, and CanCan redirects to root_url on AccessDenied exceptions. This shouldn't be an issue if the website is managed properly, but that's not gone well in the past.<commit_after>class Admin < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :confirmable, :registerable, :lockable, :timeoutable and :omniauthable
  devise :token_authenticatable, :database_authenticatable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
  attr_accessible :role_ids

  validates :role_ids, presence: true

  before_save :ensure_authentication_token

  has_many :assignments, dependent: :destroy
  has_many :roles, through: :assignments
end

{'fraction_non_alphanumeric': 0.06797853309481217, 'fraction_numerical': 0.0, 'mean_word_length': 5.658730158730159, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4510281', 'n_tokens_mistral': 475, 'n_tokens_neox': 445, 'n_words': 173}