Sha256: 6cd42e69731d9d7299b29f9a6093573ad74c5f589789e0c8b21b3e81c88ce3ca

Contents?: true

Size: 739 Bytes

Versions: 5

Compression:

Stored size: 739 Bytes

Contents

module Blacksand
  class Dashboard::BaseController < ActionController::Base
    layout 'blacksand/dashboard'

    before_action :_authenticate!
    before_action :_authorize!

    helper_method :_current_user
    helper_method :visible?

    attr_reader :authorization_adapter

    private
    def _authenticate!
      instance_eval(&Blacksand.authenticate_with)
    end

    def _authorize!
      instance_eval(&Blacksand.authorize_with)
    end

    def _current_user
      instance_eval(&Blacksand.current_user_method)
    end

    def visible?(action, object)
      # 如果启用了授权
      if self.authorization_adapter
        return self.authorization_adapter.authorized?(action, object)
      end

      true
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacksand-2.5.0 app/controllers/blacksand/dashboard/base_controller.rb
blacksand-2.4.1 app/controllers/blacksand/dashboard/base_controller.rb
blacksand-2.4.0 app/controllers/blacksand/dashboard/base_controller.rb
blacksand-2.3.0 app/controllers/blacksand/dashboard/base_controller.rb
blacksand-2.2.2.1 app/controllers/blacksand/dashboard/base_controller.rb