<commit_before>class UsersController < ApplicationController
  
  def activate
    @user = User.find_using_perishable_token(params[:id], 1.week)

    if @user.nil?
      flash[:warning] = "Invalid activation link. If you have reset your password more than once, make sure that you are using the most recent activation email."
      redirect_to root_path
    else
      if !@user.activated
        activated = @user.activate!
      end
      if @user.has_password?
        if @user.activated
          @user.deliver_activation_confirmation!
          UserSession.create(@user, true)
          flash_message(:notice, "Thanks, your account has been activated and you are now signed in.")
          redirect_to root_url
        else
          flash_message(:notice, "Your account account could not be activated. Please contact support.")
          redirect_to root_url
        end
      else
        redirect_to edit_password_user_url(@user.perishable_token)
      end
    end
  end
  
  def edit_password
    @user = current_user
  end
  
  def update_password
    @user = current_user
    @user.password = <PASSWORD>[:<PASSWORD>]['password']
    @user.password_confirmation = params[:user]['<PASSWORD>']
    
    if @user.save && @user.has_password?
      redirect_to root_url
    else
      render :action => 'edit_password'
    end
  end
  
end<commit_msg>user fix<commit_after>class UsersController < ApplicationController
  
  def activate
    @user = User.find_using_perishable_token(params[:id], 1.week)

    if @user.nil?
      flash[:warning] = "Invalid activation link. If you have reset your password more than once, make sure that you are using the most recent activation email."
      redirect_to root_path
    else
      if !@user.activated
        activated = @user.activate!
      end
      if @user.has_password?
        if @user.activated
          @user.deliver_activation_confirmation!
          UserSession.create(@user, true)
          flash_message(:notice, "Thanks, your account has been activated and you are now signed in.")
          redirect_to root_url
        else
          flash_message(:notice, "Your account account could not be activated. Please contact support.")
          redirect_to root_url
        end
      else
        redirect_to edit_password_user_url(@user.perishable_token)
      end
    end
  end
  
  def edit_password
    @user = current_user || User.find_using_perishable_token(params[:id], 1.week)
  end
  
  def update_password
    @user = current_user || User.find_using_perishable_token(params[:id], 1.week)
    @user.password = params[:user]['password']
    @user.password_confirmation = params[:user]['password_<PASSWORD>']
    
    if @user.save && @user.has_password?
      redirect_to root_url
    else
      render :action => 'edit_password'
    end
  end
  
end
{'fraction_non_alphanumeric': 0.08226950354609928, 'fraction_numerical': 0.0014184397163120568, 'mean_word_length': 2.7916666666666665, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5812763', 'n_tokens_mistral': 812, 'n_tokens_neox': 799, 'n_words': 224}