Hello,
You can use @auth* decorators to force authentication to single functions,
but how you can force authentication to your whole application?.
I use this, just after defining auth:
if not auth.is_logged_in():
# avoid infinite recursion
if request.url != auth.settings.login_url:
# after authentication go to the intended url
redirect(auth.settings.login_url + '?_next=' + request.env.
request_uri)
Any better aproach?.
You can also exclude certain controllers and/or functions:
if not auth.is_logged_in():
if request.controller != 'util' and request.function !=
'change_language':
# avoid infinite recursion
if request.url != auth.settings.login_url:
# after authentication go to the intended url
redirect(auth.settings.login_url + '?_next=' + request.env.
request_uri)
Regards.
--
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.