Seems that the best way to do this is
@auth.requires_login()
def index():
"""
Redirects user to the appropriate controller based on the group user
belongs
to
"""
if auth.has_membership('student'):
redirect(URL(f=workspace))
elif auth.has_membership('instructor'):
redirect(URL(f=dashboard))
----- Original Message ----
> From: Luther Goh Lu Feng <[email protected]>
> To: web2py <[email protected]>
> Sent: Wed, October 20, 2010 2:03:33 PM
> Subject: Re: Getting the user id for login redirect
>
> So a quick google on the google group shows that auth.user_id is the variable
> I
>
> am looking for.
>
> I am really sorry for spamming the list for this simple question. Will
> search
> more thoroughly next time.
>
>
> ----- Original Message ----
> > From: Luther Goh Lu Feng <[email protected]>
> > To: web2py <[email protected]>
> > Sent: Wed, October 20, 2010 1:52:19 PM
> > Subject: Getting the user id for login redirect
> >
> > Good day,
> >
> > I am trying to construct a login system that redirects the login to
>different
>
>
> > controllers depending on which membership they belong to. Below is the
> > code
>
> > snippet. I need some tips to access the variable containing the user id.
> > I
> > believe I might need to look at a session variable. If there are any
> > other
>
> >
> > @auth.requires_login()
> > def index():
> > """
> > Redirects user to the appropriate controller based on the group user
> >belongs
> >
> > to
> > """
> > membership = db.auth_membership(user_id=SOME_SESSION_USER_VARIABLE)
> > if membership.group_id == 2:
> > redirect(URL(f=workspace))
> > elif membership.group_id == 3:
> > redirect(URL(f=dashboard))
> >
> >
> >
> >
> >
>
>
>
>