Wherever you are creating the link:
href="{{=URL('fsr', 'bondsmanProfile' if auth.has_membership('bondsman')
else 'publicProfile')}}"
Also, the @auth.requires_membership() decorator already requires login by
default, so there is no need to precede it with the @auth.requires_login()
decorator.
Anthony
On Monday, August 8, 2016 at 3:26:05 AM UTC-4, Kevin Reilley wrote:
>
> I'd have two user types public and bondsman. I'd like for an href on the
> home page to redirect to a different view depending on the group that the
> user is a part of. If they are logged in as public the redirect should go
> to fsr/publicProfile and if they are logged in as a bondsman it should
> redirect to fsr/bondsmanProfile.
>
> In my controller I have this
>
> def index(): return dict(message="hello from fsr.py")
>
> def home():
> return locals()
>
>
> def publicProfile():
> return locals()
>
> @auth.requires_login()
> @auth.requires_membership('bondsman')
> def bondsmanProfile():
> return locals()
>
> from the view "fsr/home" I would like to have a link to the fsr/publicProfile
> or fsr/bondsmanProfile and have some
> code that will determine which view I'm redirected to based on how I'm logged
> in.
>
> something like an if-then statement would be great but I can't find any
> documentation on how to do this
> In pseudo code what I want to write in the view is:
>
> If User is logged in as Bondsman, href="project/fsr/bondsmanProfile
> Else href="project/fsr/publicProfile
>
> I may be going about this pretty unconventionally too, so feel free to
> educate me on how role based redirection might be done.
> Thanks in advance!
>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.