I mentioned this in another thread (https://groups.google.com/d/msg/web2py/XaHiLQHQ9X0/N8J1PqUxK6YJ), but an entirely different approach is to skip auth.login() altogether, write all the login logic yourself, and use auth.login_bare() just to check the submitted credentials (in addition to returning True or False, it also updates the session and auth.user in case of successful login).
Anthony On Thursday, March 22, 2012 11:08:51 PM UTC-4, Anthony wrote: > > @anthony: actually, on closer inspection, the doc does go into some >> details: >> http://web2py.com/books/default/chapter/29/4#HTTP-and-redirect<http://web2py.com/books/default/chapter/29/4#HTTP-and-redirect> >> >> but I'm still experimenting with how to get it to execute a script. > > > Something like: > > def myonaccept(form): > [do stuff] > response.js = 'some JS code' > raise HTTP(200, response.render()) > > In that case, raise HTTP() will immediately return a response without > proceeding through the remainder of auth.login() (thus avoiding the > subsequent redirect). As long as the original request was made via an Ajax > component, setting response.js before calling raise HTTP() will result in > web2py adding the JS code as a response header before returning the > response. > > Note, response.render() can take a view argument and a context argument > (i.e., a dict) if needed. HTTP() can also take arbitrary keyword arguments, > which will be converted to response headers. > > Anthony > >

