app/controllers/rich/cms_controller.rb in rich_cms-2.1.7 vs app/controllers/rich/cms_controller.rb in rich_cms-3.0.0
- old
+ new
@@ -1,65 +1,36 @@
-
module Rich
class CmsController < ::ApplicationController
+ before_filter :require_login, :except => [:display, :position]
- before_filter :require_current_rich_cms_admin, :except => [:display, :position, :login]
-
def display
(session[:rich_cms] ||= {})[:display] = params[:display]
request.xhr? ? render(:nothing => true) : redirect_to(request.referrer)
end
def position
session[:rich_cms][:position] = params[:position]
render :nothing => true
end
- def login
- case rich_cms_auth.logic
- when :authlogic
- @current_rich_cms_admin_session = rich_cms_authenticated_class.new params[key = rich_cms_authenticated_class.name.underscore.gsub("/", "_")]
- authenticated = @current_rich_cms_admin_session.save
-
- after_rich_cms_login authenticated, key
- end
+ def update
+ render :json => Cms::Content::Item.new(params[:content_item]).save
end
- def logout
- case rich_cms_auth.logic
- when :authlogic
- (@current_rich_cms_admin_session ||= rich_cms_authenticated_class.find).destroy
- end
- session[:rich_cms] = nil
+ private
- after_rich_cms_logout
- end
-
- unless ::ApplicationController.instance_methods.include?("after_rich_cms_login")
- def after_rich_cms_login(authenticated, key)
+ def require_login
+ if Rich::Cms::Auth.login_required?
if request.xhr?
render :update do |page|
- if authenticated
- page.reload
- else
- page["##{key}_#{rich_cms_authentication_inputs.first}"].focus
- end
+ page.reload
end
else
redirect_to request.referrer
end
+ return false
end
+ true
end
- unless ::ApplicationController.instance_methods.include?("after_rich_cms_logout")
- def after_rich_cms_logout
- redirect_to request.referrer
- end
- end
-
- def update
- render :json => Cms::Content::Item.new(params[:content_item]).save
- end
-
end
-
-end
+end
\ No newline at end of file