Ajax Login with Acegi

Sanjiv Jivan has written about how he has integrated an ajax based login form to the Acegi Spring module for Auth and Auth. His implementation contains a ServletFilter in J2EE land, and JavaScript in the client:
JAVASCRIPT:
  1. function ajaxLogin() {
  2. Element.update('loginMessage', 'Sending request ...');
  3. Element.show('loginMessage');
  4. var opt = {
  5. method: 'post',
  6. postBody: Form.serialize($('loginForm')) + '&ajax=true',
  7. onSuccess: function(response) {
  8. var msg = response.responseText;
  9. if ("error:" == msg.substr(0, 6)) {
  10. var fp = "<font color='red'>" + msg.substring(6, msg.length) + '</font><br /><a xhref="forgetPwd.html" mce_href="forgetPwd.html">Forget Password?</a>';
  11. Element.update('loginMessage', fp);
  12. } else if ("url:" == msg.substr(0, 4)) {
  13. location.href = msg.substring(4, msg.length);
  14. } else if ("message:" == msg.substr(0, 8)) {
  15. Element.update('loginMessage', msg.substring(8, msg.length));
  16. }
  17. }
  18. }
  19. new Ajax.Request('j_acegi_security_check', opt);
  20. }

Ajax Login with Acegi

Sanjiv Jivan has written about how he has integrated an ajax based login form to the Acegi Spring module for Auth and Auth.

His implementation contains a ServletFilter in J2EE land, and JavaScript in the client:

JAVASCRIPT:
  1.  
  2. function ajaxLogin() {
  3.     Element.update('loginMessage', 'Sending request ...');
  4.     Element.show('loginMessage');
  5.     var opt = {
  6.  
  7.         method: 'post',
  8.  
  9.         postBody: Form.serialize($('loginForm')) + '&ajax=true',
  10.  
  11.  
  12.         onSuccess: function(response) {
  13.             var msg = response.responseText;
  14.             if ("error:" == msg.substr(0, 6)) {
  15.                 var fp = "<font color='red'>" + msg.substring(6, msg.length) + '</font><br /><a href="forgetPwd.html">Forget Password?</a>';
  16.                 Element.update('loginMessage', fp);
  17.             } else if ("url:" == msg.substr(0, 4)) {
  18.                 location.href = msg.substring(4, msg.length);
  19.             } else if ("message:" == msg.substr(0, 8)) {
  20.                 Element.update('loginMessage', msg.substring(8, msg.length));
  21.             }
  22.         }
  23.     }
  24.     new Ajax.Request('j_acegi_security_check', opt);
  25. }
  26.  


August 20th, 2006

Tagged View

Tags Similar

Posts Fresh +

Categories View