<commit_before>class UsersController < ApplicationController

  get '/signup' do 
    if logged_in?
      redirect to '/users/#{current_user.slug}'
    else 
      erb :'users/signup'
    end 
  end 

  get '/users/:slug' do 
    if @user = User.find_by_slug(params[:slug])
      @workouts = @user.workouts
      erb :'users/show_user'
    else 
      redirect to '/'
    end
  end 

  post '/signup' do 
    if params[:username] == "" || params[:email] == "" || params[:password] == ""
      redirect to '/signup'
    else
      @user = User.new(:username => params[:username], :email => params[:email], :password => params[:password])
      @user.save
      session[:id] = @user.id
      redirect to '/workouts'
    end
  end

end <commit_msg>added get and post routes for '/login<commit_after>class UsersController < ApplicationController

  get '/signup' do 
    if logged_in?
      redirect to '/users/#{current_user.slug}'
    else 
      erb :'users/signup'
    end 
  end 

  get '/login' do 
    if logged_in?
      redirect to '/users/#{current_user.slug}'
    else 
      erb :'users/login'
    end  
  end 

  get '/users/:slug' do 
    if @user = User.find_by_slug(params[:slug])
      @workouts = @user.workouts
      erb :'users/show_user'
    else 
      redirect to '/'
    end
  end 

  post '/signup' do 
    if params[:username] == "" || params[:email] == "" || params[:password] == ""
      redirect to '/signup'
    else
      @user = User.new(:username => params[:username], :email => params[:email], :password => params[:password])
      @user.save
      session[:id] = @user.id
      redirect to '/workouts'
    end
  end

  post '/login' do 
    @user = User.find_by(username: params[:username])
    if @user && @user.authenticate(params[:password])
      session[:id] = @user.id
      redirect to '/users/#{current_user.slug}'
    else
      #TODO add flash error message detailing the problem with login attempt
      redirect to '/users/login'
  end 

end 
{'fraction_non_alphanumeric': 0.1415617128463476, 'fraction_numerical': 0.0, 'mean_word_length': 2.4903339191564147, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5377074', 'n_tokens_mistral': 649, 'n_tokens_neox': 629, 'n_words': 165}