Sha256: f9801ce09c261bada90aaf90f8a53f02c3b2fc2e52f498b08e215544ed86f122

Contents?: true

Size: 1.64 KB

Versions: 34

Compression:

Stored size: 1.64 KB

Contents

class PasswordResetsController < ReaderActionController
  helper :reader

  # rest gone mad! but it works, and keeps the processes well-defined.

  no_login_required
  skip_before_filter :require_reader
  before_filter :get_reader, :only => [:edit, :update]
  radiant_layout { |controller| Radiant::Config['reader.layout'] }
  
  def new
    render
  end
  
  def create
    @forgetter = Reader.find_by_email(params[:email])
    if @forgetter
      if @forgetter.activated?
        @forgetter.send_password_reset_message
        render
      else
        @forgetter.send_activation_message
        redirect_to new_reader_activation_url
      end
    else  
      @error = flash[:error] = t("reader_extension.email_unknown")
      render :action => :new  
    end  
  end

  def edit  
    unless @reader
      flash[:error] = t('reader_extension.reset_not_found')
    end
    render
  end  

  def update
    if @reader 
      @reader.password = params[:reader][:password]
      @reader.password_confirmation = params[:reader][:password_confirmation]
      if @reader.save 
        self.current_reader = @reader
        flash[:notice] = t('reader_extension.password_updated_notice')
        redirect_to default_welcome_url(@reader)
      else
        flash[:error] = t('reader_extension.password_mismatch')
        render :action => :edit 
      end  
    else
      flash[:error] = t('reader_extension.reset_not_found')
      render :action => :edit     # without @reader, this will take us back to the enter-your-code form
    end
  end  

private  

  def get_reader
    @reader = Reader.find_by_id_and_perishable_token(params[:id], params[:confirmation_code])
  end  

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.38 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.37 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.36 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.35 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.33 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.32 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.31 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.30 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.29 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.28 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.27 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.26 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.25 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.24 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.23 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.20 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.19 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.18 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.17 app/controllers/password_resets_controller.rb
radiant-reader-extension-3.0.16 app/controllers/password_resets_controller.rb