<commit_before>class DeviseMfa::TokensController < DeviseController
  include Devise::Controllers::Helpers
  prepend_before_filter :ensure_credentials_refresh
  prepend_before_filter :authenticate_scope!

  def show
   if resource.nil?
      redirect_to stored_location_for(resource_name.to_sym) || :root
    else
      render :show
    end
  end

  def update
    enabled =  (params[resource_name][:mfa_enabled] == '1')
    if (enabled ? resource.enable_mfa : resource.disable_mfa)
      mfa_set_flash_message :success, :successfully_updated
    end
    render :show
  end

  private
    def ensure_credentials_refresh
      if resource.mfa_enabled? and needs_credentials_refresh?(resource)
        mfa_set_flash_message :notice, :need_to_refresh_credentials
        redirect_to refresh_mfa_credential_path_for(resource)
      end
    end
end
<commit_msg>Update tokens_controller.rb<commit_after>class DeviseMfa::TokensController < DeviseController
  include Devise::Controllers::Helpers
  #prepend_before_filter :ensure_credentials_refresh
  prepend_before_filter :authenticate_scope!

  def show
   if resource.nil?
      redirect_to stored_location_for(resource_name.to_sym) || :root
    else
      render :show
    end
  end

  def update
    enabled =  (params[resource_name][:mfa_enabled] == '1')
    if (enabled ? resource.enable_mfa : resource.disable_mfa)
      mfa_set_flash_message :success, :successfully_updated
    end
    render :show
  end

  private
    def ensure_credentials_refresh
      if resource.mfa_enabled? and needs_credentials_refresh?(resource)
        mfa_set_flash_message :notice, :need_to_refresh_credentials
        redirect_to validate_mfa_credential_path(resource)
      end
    end
end

{'fraction_non_alphanumeric': 0.06380510440835267, 'fraction_numerical': 0.001160092807424594, 'mean_word_length': 4.211480362537764, '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': '7051219', 'n_tokens_mistral': 539, 'n_tokens_neox': 538, 'n_words': 105}