Sha256: addf5268a5e889ec16ef7dc072706e93cd4cacdc5298a6e1e77fc65d7327c845
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require 'active_support/concern' module Fortress # # The Controller module embbed all the code to "hook" Fortress to your Rails # application. # # @author zedtux # module Controller extend ActiveSupport::Concern included do Mechanism.initialize_authorisations # Add a new before_filter for all controllers append_before_filter :prevent_access! end def prevent_access! controller = Fortress::ControllerInterface.new(self) Mechanism.authorised?(controller, action_name) ? true : access_deny end # # Default access_deny method used when not re-defined in the Rails # application. # # You can re-define it within the ApplicationController of you rails # application. def access_deny flash[:error] = 'You are not authorised to access this page.' redirect_to Rails.application.routes.url_helpers.root_url end # # Class methods added to all controllers in a Rails application. # # @author zedtux # module ClassMethods def fortress_allow(actions, options = {}) Mechanism.authorise!(name, actions) Mechanism.parse_options(self, actions, options) if options.present? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fortress-0.1.0 | lib/fortress/controller.rb |