On Tuesday, April 5, 2011 3:13:22 PM UTC-4, Ross Peoples wrote: 
>
> Using the @auth.requires_login() on every function is the only way I know 
> of. However, you may be able to put something like this at the top of each 
> controller: 
>
> if auth.user is None:
>     redirect(URL('default', 'login'))
>
> However, it might cause a problem if you put that in your default 
> controller. In this case, you'd still want to use the decorator for each 
> action in the default controller, but all of your other controllers should 
> work with this at the top.
>
 
Alternatively, maybe put something like this your model file (right after 
auth is defined):
 
if not auth.user_id and not (request.controller=='default' and 
request.function=='user'):
    redirect(URL('default', 'user'))
 
That will redirect to the login page if the current user isn't logged in, 
unless the current request is already for the login page.
 
Anthony

Reply via email to