Sha256: b4f6a319228e5c08d3d7685cc7d3d125cfee5d06300b5efe416c939376704d75

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

module Commontator
  class ApplicationController < ActionController::Base
    cattr_reader :app_routes

    before_filter :get_user, :ensure_user, :set_app_routes
    
    rescue_from SecurityTransgression, :with => lambda { head(:forbidden) }
    
    protected

    def security_transgression_unless(check)
      raise SecurityTransgression unless check
    end

    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.can_be_read_by? @user
    end

    def set_app_routes
      @@app_routes = main_app
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
commontator-4.6.0 app/controllers/commontator/application_controller.rb~