A logged in page and a logged out page for the same url?

20 views
Skip to first unread message

David Ripplinger

unread,
Sep 24, 2016, 12:37:37 PM9/24/16
to web2py-users
Does anyone know how I can have the same url return a totally different page depending on whether the user is logged in or not? I'd like the home page to display a simple "Sign up / log in" page when the user is logged out and display the actual app when logged out. I'd rather not have a separate url for when they are logged into the app.

Anthony

unread,
Sep 24, 2016, 1:49:06 PM9/24/16
to web2py-users
Just put some conditional logic in the controller and/or view. For example:

{{if auth.user_id:}}
The application
{{else:}}
Sign up / login
{{pass}}

Perhaps a better option is the standard approach of decorating actions that require login, which will automatically redirect to the login page for anyone who is not logged in.

Anthony

David Ripplinger

unread,
Sep 24, 2016, 2:55:30 PM9/24/16
to web2py-users
Thank you.
Reply all
Reply to author
Forward
0 new messages