Skip to content
Browse files

Rails 3.2 and Devise 2.0 compatibility

  • Loading branch information...
1 parent 121aab4 commit 545e869c2bd7059b328abaaa0e034d82b03f3252 @Johpie committed
View
2 app/controllers/rich/cms_controller.rb
@@ -4,7 +4,7 @@ class CmsController < ::ApplicationController
def display
(session[:rich_cms] ||= {})[:display] = params[:display]
- request.xhr? ? render(:nothing => true) : redirect_to(request.referrer)
+ request.xhr? ? render(:nothing => true) : redirect_to("/")
end
def position
View
27 app/controllers/rich/cms_sessions_controller.rb
@@ -1,31 +1,36 @@
module Rich
class CmsSessionsController < ::ApplicationController
+ before_filter :allow_params_authentication!, :only => :login
def login
- success = Rich::Cms::Auth.login
+ @success = Rich::Cms::Auth.login
+
if request.xhr?
- render :update do |page|
- if success
- page.reload
- else
- page["##{Rich::Cms::Auth.klass_symbol}_#{Rich::Cms::Auth.inputs.first}"].focus
- end
+ respond_to do |format|
+ format.js
end
else
- redirect_to request.referrer
+ redirect_to "/"
end
end
def logout
Rich::Cms::Auth.logout
if request.xhr?
- render :update do |page|
- page.reload
+ respond_to do |format|
+ format.js
end
else
- redirect_to request.referrer
+ redirect_to "/"
end
end
+ private
+
+ # Tell warden that params authentication is allowed for that specific page.
+ def allow_params_authentication!
+ request.env["devise.allow_params_authentication"] = true
+ end
+
end
end
View
5 app/views/rich/cms_sessions/login.js.erb
@@ -0,0 +1,5 @@
+<% if @success %>
+ window.location.reload();
+<% else %>
+ $("#<%= Rich::Cms::Auth.klass_symbol %>_<%= Rich::Cms::Auth.inputs.first %>").focus
+<% end %>

0 comments on commit 545e869

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