<commit_before>class Users::SessionsController < Devise::SessionsController
  def create
    # attempt straight db auth first, then warden auth
    resource = if params[:login] && params[:password]
      User.authenticate(params[:login], params[:password])
    else
      warden.authenticate!(auth_options)
    end
    throw(:warden) unless resource
    set_flash_message(:notice, :signed_in) if is_navigational_format?
    sign_in(resource_name, resource)
    respond_with resource do |format|
      format.html { redirect_to after_sign_in_path_for(resource) }

      # for reasons that are unclear iPhone requests for /sessions.json are 
      # considered mobile, even though request.format is text/html, which also 
      # makes no sense.
      format.json do
        render :json => current_user.to_json(:except => [
          :encrypted_password, 
          :password_salt,
          :remember_token,
          :remember_token_expires_at,
          :confirmation_token,
          :confirmed_at,
          :state,
          :deleted_at,
          :old_preferences,
          :icon_url,
          :remember_created_at
        ])
      end
    end
  end
end
<commit_msg>Made redirect happens correctly after sign in.<commit_after>class Users::SessionsController < Devise::SessionsController
  def create
    # attempt straight db auth first, then warden auth
    resource = if params[:login] && params[:password]
      User.authenticate(params[:login], params[:password])
    else
      warden.authenticate!(auth_options)
    end
    throw(:warden) unless resource
    set_flash_message(:notice, :signed_in) if is_navigational_format?
    sign_in(resource_name, resource)
    respond_with resource do |format|
      format.html do
        if session[:return_to]
          redirect_to session[:return_to]
        else
          redirect_to after_sign_in_path_for(resource)
        end
      end

      # for reasons that are unclear iPhone requests for /sessions.json are 
      # considered mobile, even though request.format is text/html, which also 
      # makes no sense.
      format.json do
        render :json => current_user.to_json(:except => [
          :encrypted_password, 
          :password_salt,
          :remember_token,
          :remember_token_expires_at,
          :confirmation_token,
          :confirmed_at,
          :state,
          :deleted_at,
          :old_preferences,
          :icon_url,
          :remember_created_at
        ])
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07806244995996797, 'fraction_numerical': 0.0, 'mean_word_length': 2.539660056657224, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4032364', 'n_tokens_mistral': 714, 'n_tokens_neox': 690, 'n_words': 174}