Hi Anthony, again, many thanks for your valuable contributions to this
group.

> I believe auth.settings.login_next only has an effect when there is no
> session._auth_next (i.e., when the user goes directly to the login URL
> rather than getting there via an internal link or redirect).

Your logic is sound, but I'm afraid this is not the case. I am
directly going to myapp/login and then getting redirected via
session._auth_next to default/index.

> > The other problem I have is that I can't figure out how to get the
> > flow of the form submission to recognize response.js and execute the
> > ajax call after login is completed. I've tried putting response.js
> > into a function in my 0_db.py file, like this:
>
> > def myonaccept(form):
> >     response.js = ...
>
> > auth.settings.login_onaccept = [myonaccept]
>
> The problem is that the auth.login() action does a redirect after running
> the onaccept callback, so I think your response.js is getting lost. You can
> probably solve both this problem and the session._auth_next redirect
> problem by having your onaccept callback itself do a redirect (to an action
> that then sets response.js) or even raise its own HTTP() response directly.
>
> def login():
>
> >     auth.settings.captcha = None
> >     login_form = auth.login()
> >     if login_form.accepts(request):
> >         response.flash = 'yo dude'
> >         response.js = util.clean_str(
> >             'ajax("%s",[],":eval");' % URL(c='user',
> > f='cb_after_login'))
>
> That won't work because auth.login() does its own form.accepts(), and in
> the case of a successful login, it does a redirect, which will prevent the
> rest of your code from executing.
>
> Anthony

I thought this is what the auth.settings.login_onaccept = [myonaccept]
was supposed to do (see my example stated earlier). That was my first
attempt as it seemed the most logical. Am I doing something wrong
there? The second attempt, which is the if login_form.accepts(...) was
an act of desperation :-o

Reply via email to