<commit_before>class UserPasswordsController < Spree::UserPasswordsController
  layout 'darkswarm'

  before_filter :set_admin_redirect, only: :edit

  def create
    return if user_unconfirmed?

    self.resource = resource_class.send_reset_password_instructions(params[resource_name])

    if resource.errors.empty?
      set_flash_message(:success, :send_instructions) if is_navigational_format?
      respond_with resource, :location => spree.login_path
    else
      respond_to do |format|
        format.html do
          respond_with_navigational(resource) { render :new }
        end
        format.js do
          render json: { error: t('email_not_found') }, status: :not_found
        end
      end
    end
  end

  private

  def set_admin_redirect
    session["spree_user_return_to"] = params[:return_to] if params[:return_to]
  end

  def user_unconfirmed?
    user = Spree::User.find_by_email(params[:spree_user][:email])
    if user && !user.confirmed?
      render json: { error: t('email_unconfirmed') }, status: :unauthorized
    end

    user && !user.confirmed?
  end
end<commit_msg>Extract json render from :user_confirmed? method<commit_after>class UserPasswordsController < Spree::UserPasswordsController
  layout 'darkswarm'

  before_filter :set_admin_redirect, only: :edit

  def create
    render_unconfirmed_response && return if user_unconfirmed?

    self.resource = resource_class.send_reset_password_instructions(params[resource_name])

    if resource.errors.empty?
      set_flash_message(:success, :send_instructions) if is_navigational_format?
      respond_with resource, :location => spree.login_path
    else
      respond_to do |format|
        format.html do
          respond_with_navigational(resource) { render :new }
        end
        format.js do
          render json: { error: t('email_not_found') }, status: :not_found
        end
      end
    end
  end

  private

  def set_admin_redirect
    session["spree_user_return_to"] = params[:return_to] if params[:return_to]
  end

  def render_unconfirmed_response
    render json: { error: t('email_unconfirmed') }, status: :unauthorized
  end

  def user_unconfirmed?
    user = Spree::User.find_by_email(params[:spree_user][:email])
    user && !user.confirmed?
  end
end
{'fraction_non_alphanumeric': 0.08663148636763413, 'fraction_numerical': 0.0, 'mean_word_length': 3.671457905544148, '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': '5206873', 'n_tokens_mistral': 712, 'n_tokens_neox': 684, 'n_words': 152}