Sha256: abe175eb6ba99289b8e13003737c5d595180ac5bdf76ce37a1974ac0ce9204b7

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 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
    @reader = Reader.find_by_email(params[:email])
    if @reader
      if @reader.activated?
        @reader.send_password_reset_message
        render
      else
        @reader.send_activation_message
        redirect_to new_reader_activation_url
      end
    else  
      @error = flash[:error] = t("email_unknown")
      render :action => :new  
    end  
  end

  def edit  
    unless @reader
      flash[:error] = t('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('password_updated_notice')
        redirect_to url_for(@reader)
      else
        flash[:error] = t('password_mismatch')
        render :action => :edit 
      end  
    else
      flash[:error] = t('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

12 entries across 12 versions & 1 rubygems

Version Path
radiant-reader-extension-1.3.13 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.12 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.11 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.10 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.9 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.8 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.7 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.6 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.4 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.3 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.1 app/controllers/password_resets_controller.rb
radiant-reader-extension-1.3.0 app/controllers/password_resets_controller.rb