App Engine, if elif is still running on dev, but not in production

When I run the following code

user = users.get_current_user() if users.is_current_user_admin(): loggedin = 'Admin' elif user: loggedin = 'User' else: loggedin = 'Anonymous' 

in development environment I get Admin when I log in as administrator, user as user and anonymous when I am not logged in. When in production I always get Anonymous. Why is this not working?

0
source share
2 answers

The problem has nothing to do with if / elif / else or users.create_login_url (). The problem is that App Engine does not recognize the registered user in the HTTP request when the user is logged in with HTTPS with users.create_login_url (). I created a new question on this here . I believe this has something to do with how the cookie is set.

The reason code worked on Dev rather than production is because the development environment handles HTTPS URLs, redirects it to http and serves the request, avoiding the problem.

+1
source

First you need to login through users.create_login_url ()

0
source

Source: https://habr.com/ru/post/1416433/


All Articles