Hi, To handle authentication, my system checks for the user''s credentials (cookie) and if the login has expired, redirects the user to a login page. This works fine except when the user is on a page that has an autocomplete text box and starts typing into the box. I am wondering if there is a way to detect that the server has returned a redirect and tell Ajax.Autocompleter to repaint the whole screen. Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Don''t know what you''re sever side environment is, but if you explicitly create and HTTP status code other than 200 (or any in the 200''s) the prototype Ajax objects will call their onFailure function. So, in PHP you could do this: header("HTTP/1.0 403 Forbidden"); And, on the client side, the Ajax object would fire the onFailure routine which could then be used to repaint the screen or force a re-login or whatever. -- Dash -- grigora wrote:> Hi, > > To handle authentication, my system checks for the user''s credentials > (cookie) and if the login has expired, redirects the user to a login > page. This works fine except when the user is on a page that has an > autocomplete text box and starts typing into the box. > I am wondering if there is a way to detect that the server has > returned a redirect and tell Ajax.Autocompleter to repaint the whole > screen. > > Thanks. > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
David Dashifen Kees wrote:> Don''t know what you''re sever side environment is, but if you explicitly > create and HTTP status code other than 200 (or any in the 200''s) the > prototype Ajax objects will call their onFailure function. So, in PHP > you could do this: > > header("HTTP/1.0 403 Forbidden"); > > And, on the client side, the Ajax object would fire the onFailure > routine which could then be used to repaint the screen or force a > re-login or whatever.Even better would be to set an ''on403'' handler to specifically handle auth failures rather than treating all failures as auth failures. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
True, that would be better *scurries off to update code* -- Dash -- Michael Peters wrote:> David Dashifen Kees wrote: > >> Don''t know what you''re sever side environment is, but if you explicitly >> create and HTTP status code other than 200 (or any in the 200''s) the >> prototype Ajax objects will call their onFailure function. So, in PHP >> you could do this: >> >> header("HTTP/1.0 403 Forbidden"); >> >> And, on the client side, the Ajax object would fire the onFailure >> routine which could then be used to repaint the screen or force a >> re-login or whatever. >> > > Even better would be to set an ''on403'' handler to specifically handle auth > failures rather than treating all failures as auth failures. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
That''s mostly true. Redirect headers (e.g., 301, 302), are handled transparently by the browser, so your Javascript will never see ''em. TAG On Apr 10, 2007, at 6:47 AM, David Dashifen Kees wrote:> > Don''t know what you''re sever side environment is, but if you > explicitly > create and HTTP status code other than 200 (or any in the 200''s) the > prototype Ajax objects will call their onFailure function.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 10, 7:48 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> That''s mostly true. Redirect headers (e.g., 301, 302), are handled > transparently by the browser, so your Javascript will never see ''em. > > TAG > > On Apr 10, 2007, at 6:47 AM, David Dashifen Kees wrote: > > > > > Don''t know what you''re sever side environment is, but if you > > explicitly > > create and HTTP status code other than 200 (or any in the 200''s) the > > prototype Ajax objects will call their onFailure function.Thanks for all the comments. My handler (modperl) returns a redirect header with HTTP 302. However, unlike how you describe it, the login page actually appears in the <div> where the response text should ideally appear when the credentials are still valid, which leads me to think that JavaScript (and not the browser) still has control of what''s returned. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
> Even better would be to set an ''on403'' handler to specifically handle auth > failures rather than treating all failures as auth failures. >This is exactly what I need. I am very new to Ajax so I would appreciate an example of how to do this (both setting up the handler AND actually forcing a whole page reload). I am using the Ajax.Autocompleter object from the script.aculo.us library. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
What I''m saying is the browser performs the redirect automatically-- so your AJAX object won''t see the 302 (et al) header in its status. It will see whatever status code from the page it redirected to--in your case, probably 200. Yes, it will get whatever response the redirect target provides (login, in this case), but you have no programatic way (to my knowledge) of determining a redirect occurred without parsing the result for values you know your application should return. And as to your question in your other email: Force a page refresh/ redirect by changing document.location.href. It''s standard Javascript; search Google for some good examples. To modify the example from the Prototype docs: new Ajax.Updater(''items'', ''/items'', { parameters: { text: $F(''text'') }, insertion: Insertion.Bottom, on403: function (transport) { // <== new handler // Authentication timeout; redirect document.location.href = newUrl; } }); TAG On Apr 11, 2007, at 1:24 AM, grigora wrote:> > On Apr 10, 7:48 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: >> That''s mostly true. Redirect headers (e.g., 301, 302), are handled >> transparently by the browser, so your Javascript will never see ''em. >> >> TAG > > Thanks for all the comments. My handler (modperl) returns a redirect > header with HTTP 302. However, unlike how you describe it, the login > page actually appears in the <div> where the response text should > ideally appear when the credentials are still valid, which leads me to > think that JavaScript (and not the browser) still has control of > what''s returned.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 11, 7:44 am, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> What I''m saying is the browser performs the redirect automatically-- > so your AJAX object won''t see the 302 (et al) header in its status. > It will see whatever status code from the page it redirected to--in > your case, probably 200. > > Yes, it will get whatever response the redirect target provides > (login, in this case), but you have no programatic way (to my > knowledge) of determining a redirect occurred without parsing the > result for values you know your application should return. > > And as to your question in your other email: Force a page refresh/ > redirect by changing document.location.href. It''s standard > Javascript; search Google for some good examples. > > To modify the example from the Prototype docs: > new Ajax.Updater(''items'', ''/items'', { > parameters: { text: $F(''text'') }, > insertion: Insertion.Bottom, > on403: function (transport) { // <== new handler > // Authentication timeout; redirect > document.location.href = newUrl; > } > > }); >I am finally getting around to fixing this issue. The problem is that Ajax.Autocompleter (script.aculo.us) does not seem to have either onFailure or on302 handlers. Any suggestions? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---