Sha256: 501ad85a73c11214e4a6e23ddb0fef8fa835d3622ccad699ced13295478bfc6d

Contents?: true

Size: 967 Bytes

Versions: 6

Compression:

Stored size: 967 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
      security_transgression_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])
      security_transgression_unless !@thread.commontable.nil?
    end
    
    def set_commontable_url
      self.commontable_url = @thread.config.commontable_url_proc.call(
                               @thread.commontable, main_app)
    end

    def security_transgression_unless(check)
      raise SecurityTransgression unless check
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.5.4 app/controllers/commontator/application_controller.rb
commontator-4.5.3 app/controllers/commontator/application_controller.rb
commontator-4.5.2 app/controllers/commontator/application_controller.rb
commontator-4.5.1 app/controllers/commontator/application_controller.rb
commontator-4.5.0 app/controllers/commontator/application_controller.rb
commontator-4.4.1 app/controllers/commontator/application_controller.rb