Skip to content
Browse files

Setup basic access callback to restrict who can see lists

  • Loading branch information...
1 parent e4991ca commit 593bb8521eb83b691745b07505802e5e2692a416 @jackdempsey committed Jun 18, 2012
Showing with 16 additions and 0 deletions.
  1. +9 −0 app/controllers/lists/application_controller.rb
  2. +7 −0 lib/lists.rb
View
9 app/controllers/lists/application_controller.rb
@@ -1,4 +1,13 @@
module Lists
class ApplicationController < ActionController::Base
+ before_filter :authenticate_user
+
+ protected
+
+ def authenticate_user
+ unless Lists.access_callback.call
+ raise "Authentication failed."
+ end
+ end
end
end
View
7 lib/lists.rb
@@ -1,6 +1,13 @@
require "lists/engine"
+require 'active_support/dependencies'
require 'haml'
require 'acts_as_list'
module Lists
+ mattr_accessor :access_callback
+ @@access_callback = -> { respond_to?(:current_admin_user) ? current_admin_user : false }
+
+ def self.setup
+ yield self
+ end
end

0 comments on commit 593bb85

Please sign in to comment.
Something went wrong with that request. Please try again.