This works!!

Thank you so much 

El jueves, 31 de octubre de 2019, 3:50:16 (UTC-3), Ruslan Gareev escribió:
>
> maybe make this?
>
> @auth.requires_login()
> def index():
>     if auth.has_membership(group_id='administrador'):
>         redirect(URL('default', 'indexAdmin'))
>     else:    
>         redirect(URL('default', 'indexSchool'))
>
> @auth.requires_membership(role="administrador")
> def indexAdmin():
>     ...your_code...
>
> @auth.requires_login()
> def indexSchool():
>    ...your code...
>
>
>
>
> четверг, 31 октября 2019 г., 8:57:39 UTC+5 пользователь Cristina Sig 
> написал:
>>
>> I tried your suggestion but it doesn't work.
>> It keeps loading the index page and doesn't allow me to see the login 
>> page.
>>
>>
>> El miércoles, 30 de octubre de 2019, 23:15:37 (UTC-3), Ruslan Gareev 
>> escribió:
>>>
>>> Hi, try:
>>> @auth.requires(lambda: check_membership())
>>> def index():
>>>     ...your code...
>>>
>>>
>>>
>>> четверг, 31 октября 2019 г., 5:51:34 UTC+5 пользователь Cristina Sig 
>>> написал:
>>>>
>>>> Hi everyone,
>>>>
>>>> I have two different memberships. One is 'Admin' and the other one is 
>>>> 'Schools' and what I want to do is redirect to different index pages 
>>>> depending if I'm login as Admin or as School.
>>>> This is my try:
>>>>
>>>> Default.py
>>>> def check_membership():
>>>>     if auth.has_membership(group_id='administrador'):
>>>>         redirect(URL('default', 'indexAdmin'))
>>>>     elseif:    
>>>>         redirect(URL('default', 'indexSchool'))
>>>>
>>>>
>>>> @auth.requires('check_membership')
>>>> def index():
>>>>     return dict(message=T("Welcome!"))
>>>>
>>>> It didn't work at all, so any suggestions how to achieve that?
>>>>
>>>> Thanks!!
>>>>
>>>>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/3383a8f2-4956-4be6-afd7-d7587d31b71c%40googlegroups.com.

Reply via email to