[PATCH conductor] BZ 858997 - Fix AJAX error handling
Matt Wagner
matt.wagner at redhat.com
Thu Sep 20 22:31:13 UTC 2012
A recent patch for the login page broke our handling of 401s
on AJAX responses. That has an easy fix, but broke the login
page's error-handling.
This fix modifies the login page to handle 401s. It's the most
elegant fix I could find at this time -- ideally we should pull
some part of this 401 handling up to converge-ui but that is
out of scope for today.
https://bugzilla.redhat.com/show_bug.cgi?id=858997
---
src/app/controllers/user_sessions_controller.rb | 2 +-
src/app/views/user_sessions/new.html.haml | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/user_sessions_controller.rb b/src/app/controllers/user_sessions_controller.rb
index 8f3385d..ac0607f 100644
--- a/src/app/controllers/user_sessions_controller.rb
+++ b/src/app/controllers/user_sessions_controller.rb
@@ -48,7 +48,7 @@ class UserSessionsController < ApplicationController
format.xml { head :unauthorized }
flash.now[:warning] = t "user_sessions.flash.warning.login_failed"
format.html { render :action => :new }
- format.js { render :layout => false }
+ format.js { head :unauthorized }
end
end
diff --git a/src/app/views/user_sessions/new.html.haml b/src/app/views/user_sessions/new.html.haml
index ec04542..b195b1b 100644
--- a/src/app/views/user_sessions/new.html.haml
+++ b/src/app/views/user_sessions/new.html.haml
@@ -17,10 +17,23 @@
= "| #{@title}" unless @title.blank?
= content_for :notifications do
- = render :partial => 'notifications' if flash[:warning].present?
+ %div.error.hidden
+ %p.text= t("user_sessions.flash.warning.login_failed")
= content_for :login_logo do
= image_tag 'login-card-logo-upstream.png'
= content_for :footer do
= render :partial => 'layouts/footer'
+
+= content_for :extra do
+ %script
+ :plain
+ $(document).bind("ajax:complete",
+ function(evt, data, status, xhr){
+ if(status == "error") {
+ $('.error').show();
+ $('form .spinner').fadeOut('fast');
+ }
+ }
+ );
--
1.7.7.6
More information about the aeolus-devel
mailing list