Skip to content

Commit

Permalink
refactor authentication to be more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiaanterhorst committed Jul 12, 2012
1 parent 8f1db75 commit bfb96e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/controllers/rich/files_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Rich
class FilesController < ApplicationController


before_filter :authenticate_rich_user

layout "rich/application"

def index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module Rich
class ApplicationController < ActionController::Base

before_filter :authenticate_rich_user

module Authorize
def authenticate_rich_user
send(Rich.authentication_method) unless Rich.authentication_method == :none
end

end
end
end
10 changes: 9 additions & 1 deletion lib/rich/engine.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'paperclip'
require 'rack/raw_upload'
require "rich/authorize"

module Rich
class Engine < Rails::Engine
Expand All @@ -9,6 +10,13 @@ class Engine < Rails::Engine
app.config.assets.precompile += %w(rich/base.js rich/editor.css rich/rich_editor.css)
app.middleware.use 'Rack::RawUpload', :paths => ['/rich/files']
end


initializer 'myengine.app_controller' do |app|
ActiveSupport.on_load(:action_controller) do
include Rich::Authorize
end
end


end
end

0 comments on commit bfb96e9

Please sign in to comment.