auth.settings.login_onaccept=URL('afterlogin') #assuming it's in the
default controller.
does the same.
For reference, the other callsbacks *(before) db io* are:
auth.settings.login_onvalidation = []
auth.settings.register_onvalidation = []
auth.settings.profile_onvalidation = []
auth.settings.retrieve_password_onvalidation = []
auth.settings.reset_password_onvalidation = []
and *after db io*
auth.settings.login_onaccept = []
auth.settings.register_onaccept = []
auth.settings.profile_onaccept = []
auth.settings.verify_email_onaccept = []
On Friday, November 11, 2011, Rahul wrote:
> Hey All,
> I got it working with the below code -
>
> If you need to redirect to a url - after Auth login -
>
> In your controller - (default.py) - Just add the below function and
> call it with "auth.settings.login_onaccept" as shown below.
> #------------------
> def afterlogin(form):
> redirect("http://127.0.0.1:8000/ProjecName/default/main")
>
> auth.settings.login_onaccept = lambda form:afterlogin(form)
>
> def main():
> #response.view='default/main.html'
> return dict()
> #----------------------------
> Note:
> 1. You should have main.html and its corresponding function in default
> controller. i.e. Where you would like to direct the file
> 2. You do not need to add anything for this in db.py Just these 3
> lines should make it work . It works for me.
>
> Thanks All,
>
> Cheers, Rahul D
> (www.flockbird.com - powered by web2py)
>
> PS: We can close this thread!
>
>
> On Nov 11, 4:09 pm, Cahya Dewanta <[email protected] <javascript:;>>
> wrote:
> > 1. in your db.py you should define
> >
> > def go_log(object):
> > redirect(URL('default','samples')) #default is the controller,
> > samples is the action.
> >
> > auth.settings.login_onaccept = go_log
> >
> > 2. in your default.py create a action
> >
> > def samples():
> > return dict()
> >
> > 3. you should have created file samples.html in your views/default dir
> >
> > tables are models. you create them when you call db.define_table()