Sha256: e885ed0898721d3d2866d2b9848cb933a81d1304e8090261af1743ffe26b5832

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

class PasswordResetsController < BaseController

  before_filter :require_no_user
  before_filter :load_user_using_perishable_token, :only => [ :edit, :update ]

  def new
  end

  def create
    @user = User.find_by_email(params[:email])
    if @user
      @user.deliver_password_reset_instructions!

      flash[:info] = :your_password_reset_instructions_have_been_emailed_to_you.l      

      redirect_to login_path
    else
      flash[:error] = :sorry_we_dont_recognize_that_email_address.l      

      render :action => :new
    end
  end

  def edit
  end

  def update
    @user.password = params[:password]
    @user.password_confirmation = params[:password_confirmation]

    if @user.save
      flash[:notice] = :your_changes_were_saved.l

      redirect_to dashboard_user_path(@user)
    else
      flash[:error] = @user.errors.full_messages.to_sentence
      render :action => :edit
    end
  end


  private

  def load_user_using_perishable_token
    @user = User.find_using_perishable_token(params[:id])
    unless @user
      flash[:error] = :an_error_occurred.l
      redirect_to login_path
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
community_engine-2.3.1 app/controllers/password_resets_controller.rb
community_engine-2.3.0 app/controllers/password_resets_controller.rb
community_engine-2.1.0 app/controllers/password_resets_controller.rb
community_engine-2.0.0 app/controllers/password_resets_controller.rb
community_engine-2.0.0.beta3 app/controllers/password_resets_controller.rb
community_engine-2.0.0.beta2 app/controllers/password_resets_controller.rb
community_engine-2.0.0.beta1 app/controllers/password_resets_controller.rb