<commit_before>class User < ApplicationRecord
  include CredentialsSyncableConcern
  include EmailSanitizableConcern

  enum loged_in_with_france_connect: {
    particulier: 'particulier',
    entreprise: 'entreprise'
  }

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :async,
    :recoverable, :rememberable, :trackable, :validatable, :confirmable

  has_many :dossiers, dependent: :destroy
  has_many :invites, dependent: :destroy
  has_many :dossiers_invites, through: :invites, source: :dossier
  has_many :piece_justificative, dependent: :destroy
  has_many :feedbacks, dependent: :destroy
  has_one :france_connect_information, dependent: :destroy

  accepts_nested_attributes_for :france_connect_information

  before_validation -> { sanitize_email(:email) }

  # Callback provided by Devise
  def after_confirmation
    link_invites!
  end

  def self.find_for_france_connect(email, siret)
    user = User.find_by(email: email)
    if user.nil?
      User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
    else
      user.update(siret: siret)<commit_msg>Add a blank line to ease readability<commit_after>class User < ApplicationRecord
  include CredentialsSyncableConcern
  include EmailSanitizableConcern

  enum loged_in_with_france_connect: {
    particulier: 'particulier',
    entreprise: 'entreprise'
  }

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :async,
    :recoverable, :rememberable, :trackable, :validatable, :confirmable

  has_many :dossiers, dependent: :destroy
  has_many :invites, dependent: :destroy
  has_many :dossiers_invites, through: :invites, source: :dossier
  has_many :piece_justificative, dependent: :destroy
  has_many :feedbacks, dependent: :destroy
  has_one :france_connect_information, dependent: :destroy

  accepts_nested_attributes_for :france_connect_information

  before_validation -> { sanitize_email(:email) }

  # Callback provided by Devise
  def after_confirmation
    link_invites!
  end

  def self.find_for_france_connect(email, siret)
    user = User.find_by(email: email)

    if user.nil?
      User.create(email: email, password: Devise.friendly_token[0, 20], siret: siret)
    else
      user.update(siret: siret)
{'fraction_non_alphanumeric': 0.08401305057096248, 'fraction_numerical': 0.0024469820554649264, 'mean_word_length': 5.25765306122449, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3172404', 'n_tokens_mistral': 811, 'n_tokens_neox': 764, 'n_words': 185}