app/controllers/manage/base_controller.rb in freeberry-0.2.7 vs app/controllers/manage/base_controller.rb in freeberry-0.2.9
- old
+ new
@@ -1,9 +1,24 @@
class Manage::BaseController < ApplicationController
- layout "manage"
-
before_filter :authenticate_user!
+ check_authorization
- filter_access_to :all
+ layout "manage"
+ respond_to :html
- respond_to :html, :xml, :json
+ protected
+
+ rescue_from CanCan::AccessDenied do |exception|
+ flash[:failure] = exception.message
+ flash[:failure] ||= I18n.t(:access_denied, :scope => [:flash, :users])
+
+ respond_to do |format|
+ format.html { redirect_to new_session_path(:user) }
+ format.xml { head :unauthorized }
+ format.js { head :unauthorized }
+ end
+ end
+
+ def current_ability
+ @current_ability ||= ::Ability.new(current_user, :manage)
+ end
end