I''m trying to come up with a general solution to catch session expiration on Ajax requests. We''re using Rails with acts_as_authenticated which redirects to a login page when the session has expired. I figure I can send indication of the expired session in json/response header/whatever. I want to catch ''em all with Responders, but regular callbacks are dispatched first and, in our app, raise exceptions and preventing my Responders from running. A friend recommended hacking in a Ajax.BeforeResponders that get serviced before normal callbacks. Any other ideas or solutions out there? Thanks, Dan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nicholas Schlueter
2008-May-06 03:32 UTC
Re: Getting Ajax.Responders dispatched before regular callbacks
I work with Dan and while we have solved our problem with what he outlined above, I think there must be a more general solution. I am sorta just brain storming but I think it would be useful if the Responders worked more like before and after filters in rails. Where when you register one you specify the execution time and if the callback explicitly returned false it would stop the execution chain. I looked at the code a little and I think you could make it without much backward compatibility issues. Anyone think this is a good idea? Nicholas On Apr 2, 4:08 pm, dmeiz <dan.hens...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to come up with a general solution to catch session > expiration on Ajax requests. We''re using Rails with > acts_as_authenticated which redirects to a login page when the session > has expired. I figure I can send indication of the expired session in > json/response header/whatever. > > I want to catch ''em all withResponders, but regular callbacks are > dispatched first and, in our app, raise exceptions and preventing myRespondersfrom running. > > A friend recommended hacking in a Ajax.BeforeResponders that get > servicedbeforenormal callbacks. > > Any other ideas or solutions out there? > > Thanks, > Dan--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
kangax
2008-May-06 20:41 UTC
Re: Getting Ajax.Responders dispatched before regular callbacks
Nicholas, I think that might be a good idea, as well as having access to "parameters" object in responder callback (parameters are unfortunately stringified before "onCreate" event is dispatched) - kangax On May 5, 11:32 pm, Nicholas Schlueter <schlue...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I work with Dan and while we have solved our problem with what he > outlined above, I think there must be a more general solution. > > I am sorta just brain storming but I think it would be useful if the > Responders worked more like before and after filters in rails. Where > when you register one you specify the execution time and if the > callback explicitly returned false it would stop the execution chain. > > I looked at the code a little and I think you could make it without > much backward compatibility issues. Anyone think this is a good idea? > > Nicholas > > On Apr 2, 4:08 pm, dmeiz <dan.hens...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m trying to come up with a general solution to catch session > > expiration on Ajax requests. We''re using Rails with > > acts_as_authenticated which redirects to a login page when the session > > has expired. I figure I can send indication of the expired session in > > json/response header/whatever. > > > I want to catch ''em all withResponders, but regular callbacks are > > dispatched first and, in our app, raise exceptions and preventing myRespondersfrom running. > > > A friend recommended hacking in a Ajax.BeforeResponders that get > > servicedbeforenormal callbacks. > > > Any other ideas or solutions out there? > > > Thanks, > > Dan--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---