<commit_before>class Administrateurs::ActivateController < ApplicationController
  include TrustedDeviceConcern

  def new
    @token = params[:token]

    user = User.with_reset_password_token(@token)
    @administrateur = user&.administrateur

    if @administrateur
      # the administrateur activates its account from an email
      trust_device(Time.zone.now)
    else
      flash.alert = "Le lien de validation d'administrateur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
      redirect_to root_path
    end
  end

  def create
    password = update_administrateur_params[:password]

    user = User.reset_password_by_token({
      password: password,
      password_confirmation: password,
      reset_password_token: update_administrateur_params[:reset_password_token]
    })

    if user&.administrateur&.errors&.empty?
      sign_in(user, scope: :user)

      flash.notice = "Mot de passe enregistré"
      redirect_to admin_procedures_path
    else
      flash.alert = administrateur.errors.full_messages
      redirect_to admin_activate_path(token: update_administrateur_params[:reset_password_token])
    end
  end

  private

  def update_administrateur_params
    params.require(:administrateur).permit(:reset_password_token, :password)
  end

  def try_to_authenticate(klass, email, password)
    resource = klass.find_for_database_authentication(email: email)

    if resource&.valid_password?(password)
      sign_in resource
    end
  end
end
<commit_msg>fix error message during admin activation error<commit_after>class Administrateurs::ActivateController < ApplicationController
  include TrustedDeviceConcern

  def new
    @token = params[:token]

    user = User.with_reset_password_token(@token)
    @administrateur = user&.administrateur

    if @administrateur
      # the administrateur activates its account from an email
      trust_device(Time.zone.now)
    else
      flash.alert = "Le lien de validation d'administrateur a expiré, #{helpers.contact_link('contactez-nous', tags: 'lien expiré')} pour obtenir un nouveau lien."
      redirect_to root_path
    end
  end

  def create
    password = update_administrateur_params[:password]

    user = User.reset_password_by_token({
      password: password,
      password_confirmation: password,
      reset_password_token: update_administrateur_params[:reset_password_token]
    })

    if user&.administrateur&.errors&.empty?
      sign_in(user, scope: :user)

      flash.notice = "Mot de passe enregistré"
      redirect_to admin_procedures_path
    else
      flash.alert = user.administrateur.errors.full_messages
      redirect_to admin_activate_path(token: update_administrateur_params[:reset_password_token])
    end
  end

  private

  def update_administrateur_params
    params.require(:administrateur).permit(:reset_password_token, :password)
  end

  def try_to_authenticate(klass, email, password)
    resource = klass.find_for_database_authentication(email: email)

    if resource&.valid_password?(password)
      sign_in resource
    end
  end
end

{'fraction_non_alphanumeric': 0.0736571244773239, 'fraction_numerical': 0.0, 'mean_word_length': 4.06514657980456, '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': '1082510', 'n_tokens_mistral': 915, 'n_tokens_neox': 916, 'n_words': 202}