<commit_before>#----------- INDEX -----------

get '/' do
  # render home page
  @users = User.all
  session[:current_results] = []
  p session
  p current_user
  erb :index
end


#----------- SESSIONS -----------

post '/sessions/error' do
  if params[:signin] == "Sign In"
    user = User.find_by(email: params[:user][:email])
    if user && user.authenticate(params[:user][:password])
    # successfully authenticated; set up session and redirect
      session[:user_id] = user.id
      redirect '/'
    else
      @error = "Invalid email or password"# an error occurred, re-render the sign-in form, displaying an error
      erb :index
    end
  elsif params[:signin] == "Sign Up"
    generate_new_user
    if @user.save
    # successfully created new account; set up the session and redirect
      session[:user_id] = @user.id
      redirect '/'
    else
      @error = "E-mail is already taken"
      erb :index
    end
  end
end

delete '/sessions/:id' do
  # sign-out -- invoked via AJAX
  return 401 unless params[:id].to_i == session[:user_id].to_i
  session.clear
  200
end


#----------- USERS -----------<commit_msg>deployment config<commit_after>#----------- INDEX -----------

get '/' do
  # render home page
  @users = User.all
  session[:current_results] = []
  p session
  p current_user
  erb :index
end


#----------- SESSIONS -----------

post '/sessions/error' do
  if params[:signin] == "Sign In"
    user = User.find_by(email: params[:user][:email])
    if user && user.authenticate(params[:user][:password])
    # successfully authenticated; set up session and redirect
      session[:user_id] = user.id
      redirect '/'
    else
      @error = "Invalid email or password"# an error occurred, re-render the sign-in form, displaying an error
      erb :index
    end
  elsif params[:signin] == "Sign Up"
    generate_user_name = params[:user][:email].scan(/(.*)@/)
    generate_user_name = generate_user_name[0][0]
    @user = User.new(params[:user])
    if @user.save
    # successfully created new account; set up the session and redirect
      @user.update(name: generate_user_name)
      session[:user_id] = @user.id
      redirect '/'
    else
      @error = "E-mail is already taken"
      erb :index
    end
  end
end

delete '/sessions/:id' do
  # sign-out -- invoked via AJAX
  return 401 unless params[:id].to_i == session[:user_id].to_i
  session.clear
  200
end


#----------- USERS -----------
{'fraction_non_alphanumeric': 0.16652960526315788, 'fraction_numerical': 0.005756578947368421, 'mean_word_length': 2.417134831460674, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1324893', 'n_tokens_mistral': 780, 'n_tokens_neox': 759, 'n_words': 222}