<commit_before># frozen_string_literal: true

require "spree/core/controller_helpers/auth"
require "spree/core/controller_helpers/common"
require "spree/core/controller_helpers/order"

module Spree
  class UserSessionsController < Devise::SessionsController
    helper 'spree/base'

    include Spree::Core::ControllerHelpers::Auth
    include Spree::Core::ControllerHelpers::Common
    include Spree::Core::ControllerHelpers::Order

    before_action :set_checkout_redirect, only: :create
    after_action :ensure_valid_locale_persisted, only: :create

    def create
      authenticate_spree_user!

      if spree_user_signed_in?
        respond_to do |format|
          format.html {
            flash[:success] = t('devise.success.logged_in_succesfully')
            redirect_back_or_default(after_sign_in_path_for(spree_current_user))
          }
          format.js {
            render json: { email: spree_current_user.login }, status: :ok
          }
        end
      else
        respond_to do |format|
          format.html {
            flash.now[:error] = t('devise.failure.invalid')
            render :new
          }
          format.js {
            render json: { message: t('devise.failure.invalid') }, status: :unauthorized
          }
        end
      end
    end

    def destroy
      # Logout will clear session data including shopfront_redirect
      #   Here we store it before actually logging out so that the redirect works correctly
      @shopfront_redirect = session[:shopfront_redirect]
      flash.notice = t('devise.sessions.signed_out')

      super
    end

    private

    attr_reader :shopfront_redirect

    def accurate_title
      Spree.t(:login)
    end<commit_msg>Remove duplicated flash notice from app/controllers/spree/user_sessions_controller.rb<commit_after># frozen_string_literal: true

require "spree/core/controller_helpers/auth"
require "spree/core/controller_helpers/common"
require "spree/core/controller_helpers/order"

module Spree
  class UserSessionsController < Devise::SessionsController
    helper 'spree/base'

    include Spree::Core::ControllerHelpers::Auth
    include Spree::Core::ControllerHelpers::Common
    include Spree::Core::ControllerHelpers::Order

    before_action :set_checkout_redirect, only: :create
    after_action :ensure_valid_locale_persisted, only: :create

    def create
      authenticate_spree_user!

      if spree_user_signed_in?
        respond_to do |format|
          format.html {
            flash[:success] = t('devise.success.logged_in_succesfully')
            redirect_back_or_default(after_sign_in_path_for(spree_current_user))
          }
          format.js {
            render json: { email: spree_current_user.login }, status: :ok
          }
        end
      else
        respond_to do |format|
          format.html {
            flash.now[:error] = t('devise.failure.invalid')
            render :new
          }
          format.js {
            render json: { message: t('devise.failure.invalid') }, status: :unauthorized
          }
        end
      end
    end

    def destroy
      # Logout will clear session data including shopfront_redirect
      #   Here we store it before actually logging out so that the redirect works correctly
      @shopfront_redirect = session[:shopfront_redirect]

      super
    end

    private

    attr_reader :shopfront_redirect

    def accurate_title
      Spree.t(:login)
    end
{'fraction_non_alphanumeric': 0.07851119511485898, 'fraction_numerical': 0.0, 'mean_word_length': 2.714902807775378, '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': '669043', 'n_tokens_mistral': 980, 'n_tokens_neox': 968, 'n_words': 212}