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'
on the development environment I get Admin when logged in as an Administrator, User as a User, and Anonymous when not logged in. When on production I always get Anonymous. Why is this not working?
You first need to log in via users.create_login_url()
The problem has nothing to do with if/elif/else or users.create_login_url(). The issue is with App Engine not recognizing a logged in user on a http request when the user logged in with HTTPS with users.create_login_url(). I've created a new question on this here. I believe it has something to do with how the cookie is being set.
The reason the code was working on Dev and not production is how the development environment handles HTTPS urls it remaps it to http and serves the request avoiding the problem.