<commit_before>class PasswordResetsController < ApplicationController

  before_filter :load_user_using_perishable_token, :only => [:edit, :update]  
  before_filter :require_no_user
  
  def new
  end
  
  def create  
    @user = User.find_by_email(params[:email])  
    if @user  
      @user.deliver_password_reset_instructions!  
      @action = t(:your_password_will_not_be_changed)
      render 'shared/confirmation_sent'
    else  
      flash[:notice] = t(:no_user_found_with_email)
      render :action => :new  
    end  
  end
  
  def edit    
  end
  
  def update
    @user.ignore_blank_passwords = false
    @user.password = params[:user][:password]  
    @user.password_confirmation = params[:user][:password_confirmation]  
    if @user.save  
      flash[:notice] = t(:password_updated)
      redirect_back_or_default root_path
    else  
      render :action => :edit  
    end
  end
  
  private
  
  def load_user_using_perishable_token 
    # not currently using a timeout on the tokens
    @user = User.find_using_perishable_token(params[:id], token_age=0)  
    unless @user && @user.registered?
      flash[:notice] = t(:could_not_find_account)
      redirect_to root_url  
    end  
  end
  
end<commit_msg>Password reset issues should be shown as errors, not notices.<commit_after>class PasswordResetsController < ApplicationController

  before_filter :load_user_using_perishable_token, :only => [:edit, :update]  
  before_filter :require_no_user
  
  def new
  end
  
  def create  
    @user = User.find_by_email(params[:email])  
    if @user  
      @user.deliver_password_reset_instructions!  
      @action = t(:your_password_will_not_be_changed)
      render 'shared/confirmation_sent'
    else  
      flash[:error] = t(:no_user_found_with_email)
      render :action => :new  
    end  
  end
  
  def edit    
  end
  
  def update
    @user.ignore_blank_passwords = false
    @user.password = params[:user][:password]  
    @user.password_confirmation = params[:user][:password_confirmation]  
    if @user.save  
      flash[:notice] = t(:password_updated)
      redirect_back_or_default root_path
    else  
      render :action => :edit  
    end
  end
  
  private
  
  def load_user_using_perishable_token 
    # not currently using a timeout on the tokens
    @user = User.find_using_perishable_token(params[:id], token_age=0)  
    unless @user && @user.registered?
      flash[:error] = t(:could_not_find_account)
      redirect_to root_url  
    end  
  end
  
end
{'fraction_non_alphanumeric': 0.08353221957040573, 'fraction_numerical': 0.0007955449482895784, 'mean_word_length': 3.0761750405186388, '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': '2757402', 'n_tokens_mistral': 832, 'n_tokens_neox': 822, 'n_words': 166}