Sha256: 89dcad2d2fbfa4f479029f539cccfd2009f1fdd4568d65bab66ee3faff8417b9

Contents?: true

Size: 840 Bytes

Versions: 6

Compression:

Stored size: 840 Bytes

Contents

module Commontator
  class ApplicationController < ActionController::Base
    before_filter :get_user, :ensure_user
    
    cattr_accessor :commontable_url
    
    rescue_from SecurityTransgression, :with => lambda { head(:forbidden) }
    
    protected
    
    def get_user
      @user = Commontator.current_user_proc.call(self)	
    end

    def ensure_user
      raise SecurityTransgression unless (@user && @user.is_commontator)
    end
    
    def get_thread
      @thread = params[:thread_id].blank? ? \
        Commontator::Thread.find(params[:id]) : \
        Commontator::Thread.find(params[:thread_id])
      raise SecurityTransgression if @thread.commontable.nil?
    end
    
    def set_commontable_url
      self.commontable_url = @thread.config.commontable_url_proc.call(main_app, @thread.commontable)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.3.0 app/controllers/commontator/application_controller.rb
commontator-4.2.2 app/controllers/commontator/application_controller.rb
commontator-4.2.1 app/controllers/commontator/application_controller.rb
commontator-4.2.0 app/controllers/commontator/application_controller.rb
commontator-4.1.2 app/controllers/commontator/application_controller.rb
commontator-4.1.1 app/controllers/commontator/application_controller.rb