<commit_before># encoding: UTF-8
class Users::OmniauthCallbacksController < ApplicationController

  def developer
    _sign_in_from_hash(__method__)
  end

  def google_oauth2
    _sign_in_from_hash(__method__)
  end


  def failure
    flash[:failure] = _('Sorry, something went wrong while logging you in.')
    redirect_to root_path
  end


  private

  def _sign_in_from_hash(provider)
    Rails.logger.info _auth_hash
    login = Login.find_or_create_from_auth_hash!(_auth_hash)
    login.auth_provider_data[provider.to_s] ||= _auth_hash.to_hash
    login.save!

    return_to = session[:return_to]

    sign_in login
    flash[:success] = _('Welcome, %{user}!') % { user: login.first_name }
    
    redirect_to return_to || ideas_path(angle: IdeasController::DefaultAngle)
  end

  def _auth_hash
    request.env['omniauth.auth']
  end
end<commit_msg>Remembers users across browser sessions (finally)<commit_after># encoding: UTF-8
class Users::OmniauthCallbacksController < ApplicationController

  def developer
    _sign_in_from_hash(__method__)
  end

  def google_oauth2
    _sign_in_from_hash(__method__)
  end


  def failure
    flash[:failure] = _('Sorry, something went wrong while logging you in.')
    redirect_to root_path
  end


  private

  def _sign_in_from_hash(provider)
    Rails.logger.info _auth_hash
    login = Login.find_or_create_from_auth_hash!(_auth_hash)
    login.auth_provider_data[provider.to_s] ||= _auth_hash.to_hash
    login.remember_me = true
    login.save!

    return_to = session[:return_to]

    sign_in login
    flash[:success] = _('Welcome, %{user}!') % { user: login.first_name }
    
    redirect_to return_to || ideas_path(angle: IdeasController::DefaultAngle)
  end

  def _auth_hash
    request.env['omniauth.auth']
  end
end
{'fraction_non_alphanumeric': 0.0886146943353898, 'fraction_numerical': 0.002243409983174425, 'mean_word_length': 4.126436781609195, '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': '3222653', 'n_tokens_mistral': 617, 'n_tokens_neox': 584, 'n_words': 120}