<commit_before># ------ MAIN PAGE ------

get '/' do
	if session[:user_id]
		id = User.find(session[:user_id])
		@username = User.find(id).name
	  erb :index
	else
	  redirect '/welcome'
	end
end

# ------ Not sure if this does anything ------

post '/' do
	redirect :index
end

# ------ Welcome, Login, Logout, Register ------

get '/welcome' do
	erb :welcome
end

get '/login' do
	erb :login
end

post '/login' do
  user = User.find_by(username: params[:username])
  redirect '/login' unless user
  if user.authenticate(params[:password])
    session[:user_id] = user.id
    redirect '/main'
  else
    erb :login
  end
end

get '/logout' do
  session[:user_id] = nil
  redirect '/welcome'
end

get '/register' do
	erb :register
end

post '/register' do
  user = User.new(name: params[:name], username: params[:username], password: params[:password])
  if user.save
    session[:user_id] = user.id
    redirect '/'
  else
    erb :register
  end
end

# ------ _____ ------

<commit_msg>cleaned up index controller file<commit_after>post '/' do
	redirect :index
end


{'fraction_non_alphanumeric': 0.16292134831460675, 'fraction_numerical': 0.0, 'mean_word_length': 2.804270462633452, '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': '887724', 'n_tokens_mistral': 381, 'n_tokens_neox': 365, 'n_words': 109}