Sha256: fd56519f4cbffb472901ff4771a9e75e1aa77ae522c79740f72f6225dfaaf726

Contents?: true

Size: 1.65 KB

Versions: 10

Compression:

Stored size: 1.65 KB

Contents

class ReaderActivationsController < ReaderActionController
  helper :reader

  no_login_required
  skip_before_filter :require_reader
  before_filter :authenticate_reader, :only => [:update]
  before_filter :check_reader_inactive
  
  radiant_layout { |controller| Radiant::Config['reader.layout'] }

  # this is just fake REST: we're actually working on the reader, not an activation object.
  # .new sends out an activation message, if we can identify the current reader
  # .update updates the reader, if the supplied token and reader id match
  # .show displays the activation in progress, ie it says 'check your email'

  def show
    expires_now
    render
  end
  
  def new
    if current_reader
      @reader = current_reader
      @reader.send_activation_message
      flash[:notice] = t("reader_extension.activation_message_sent")
    end
    expires_now
    render :action => 'show'
  end
  
  def update
    if @reader
      @reader.activate!
      self.current_reader = @reader
      redirect_to default_welcome_url(@reader)
    else
      @error = t("reader_extension.please_check_message")
      expires_now
      render :action => 'show'
    end
  end

protected

  def authenticate_reader
    # not using authlogic's find_using_perishable_token because I don't want the token to expire
    @reader = Reader.find_by_id_and_perishable_token(params[:id], params[:activation_code])
  end

  def check_reader_inactive
    if @reader && @reader.activated?
      flash[:notice] = t('reader_extension.hello').titlecase + " #{@reader.preferred_name}! " + t('reader_extension.already_active')
      redirect_back_or_to default_welcome_url(@reader)
      false
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.38 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.37 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.36 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.35 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.33 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.32 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.31 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.30 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.29 app/controllers/reader_activations_controller.rb
radiant-reader-extension-3.0.28 app/controllers/reader_activations_controller.rb