<commit_before>class SessionsController < ApplicationController

  skip_before_action :require_login, only: [:new, :one_time_token, :create]
  before_action :require_guest, except: [:destroy]

  # GET /login
  # Via: login_path
  def new
    @user = User.new(email: sign_in_params[:email])
  end

  # POST /one_time_token
  # Via: one_time_token_path
  def one_time_token
    @user = OneTimeLogin.find_user(sign_in_params[:email])
    one_time_login = OneTimeLogin.new(@user)
    if @user.valid? && one_time_login.send_authentication_check!
      @remember_me = true
      render :one_time_token
    else
      render :new
    end
  end

  # POST /login
  # Via: login_path
  # TODO spec
  def create
    email = sign_in_params[:email]
    password = <PASSWORD>_in_params[:password]
    remember_me = (sign_in_params[:remember_me] == 'true')

    @user = OneTimeLogin.find_user(email)

    if @user.valid? && @user.validate_authentication_token!(password)
      create_session(@user, remember_me)
      flash[:success] = t('.flash.authentication_success')
      redirect_to bet_path
    else
      destroy_session
      flash[:error] = t('.flash.authentication_failed')
      redirect_to login_path
    end
  end

  # GET /logout
  # Via: logout_path
  # TODO spec
  def destroy
    destroy_session
    flash[:notice] = t('.flash.logged_out')
    redirect_to root_path
  end

  private

  def sign_in_params
    params.permit(:email, :password, :remember_me)<commit_msg>Ops, quick fix to let people login again<commit_after>class SessionsController < ApplicationController

  skip_before_action :require_login, only: [:new, :one_time_token, :create]
  before_action :require_guest, except: [:destroy]

  # GET /login
  # Via: login_path
  def new
    @user = User.new(email: sign_in_params[:email])
  end

  # POST /one_time_token
  # Via: one_time_token_path
  def one_time_token
    @user = OneTimeLogin.find_user(sign_in_params[:email])
    one_time_login = OneTimeLogin.new(@user)
    if @user.valid? && one_time_login.send_authentication_check!
      @remember_me = true
      render :one_time_token
    else
      render :new
    end
  end

  # POST /login
  # Via: login_path
  # TODO spec
  def create
    email = sign_in_params[:email]
    password = sign_in_params[:password]
    remember_me = (sign_in_params[:remember_me] == 'true')

    @user = OneTimeLogin.find_user(email)

    if @user.valid? && @user.validate_authentication_token!(password)
      create_session(@user, remember_me)
      flash[:success] = t('.flash.authentication_success')
      redirect_to my_bet_path
    else
      destroy_session
      flash[:error] = t('.flash.authentication_failed')
      redirect_to login_path
    end
  end

  # GET /logout
  # Via: logout_path
  # TODO spec
  def destroy
    destroy_session
    flash[:notice] = t('.flash.logged_out')
    redirect_to root_path
  end

  private

  def sign_in_params
    params.permit(:email, :password, :remember_me)
{'fraction_non_alphanumeric': 0.099527665317139, 'fraction_numerical': 0.0, 'mean_word_length': 3.6183800623052957, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, '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': '2749712', 'n_tokens_mistral': 1016, 'n_tokens_neox': 976, 'n_words': 204}