Another simple way is  -- 
To pop out session variables like in code below for all the login session 
variables and redirect the user wherer-ever you want them to be.
This way since no valid session exists the user would be redirected to page 
where you intend them to be. 

def sign_out():
    session.pop('user_name', None)
    redirect(URL(r=request, f='login'))
    return dict()

Regards,

Rahul Dhakate

On Sunday, August 2, 2020 at 3:29:25 PM UTC+5:30 lbjc...@gmail.com wrote:

> Hi
> Thanks for this.
> I put these functions in the model.py, I hope its correct.
>
> def __on_login():
>     redirect(URL('index'))
>     return None
>
> def __on_logout():
>     redirect(URL('index')) 
>     return None
>
> On Fri, 31 Jul 2020 at 11:49, 'Annet' via web2py-users <
> web...@googlegroups.com> wrote:
>
>> What about the following?
>>
>> auth.settings.login_onaccept = lambda form: __on_login()
>> auth.settings.logout_onlogout = lambda user: __on_logout()
>>
>>
>> def __on_login():
>>     # whatever you want to do
>>     return None
>>
>>
>> def __on_logout():
>>     # whatever you want to do    
>>     return None
>>
>> To solve your problem use the request object to redirect
>>
>>
>> HTH,
>>
>> Annet
>>
>> -- 
>> 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 web2py+un...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/web2py/e80c749a-cc2e-496f-89bd-7de4c0f1ef2fo%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/web2py/e80c749a-cc2e-496f-89bd-7de4c0f1ef2fo%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/32df90f2-a489-47de-9b5f-b4a7fcacd804n%40googlegroups.com.

Reply via email to