如何users.set_current_user? [英] How to users.set_current_user?
问题描述
如何创建与谷歌应用引擎的用户类的自定义登录系统?
我做我自己的登录系统。我曾尝试 os.environ ['USER_EMAIL'] ='john.doe@example.com'
,但它不工作。我猜的信息不会被保存在一个会话中,所以如果我访问另一页则<一个href=\"http://$c$c.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/users.py\"相对=nofollow> users.get_current_user()没有什么,我已经将它设置为$ P $内存pviously。
我看到谷歌应用引擎单元测试,这是否假一登录。我觉得这些作品,因为测试是在同一会话中。我需要存储在多个会话我自己的自定义信息。
我自己也尝试设置环境变量,但没有运气。
os.environ ['USER_EMAIL'] ='john.doe@example.com
os.environ ['USER_ID'] ='todo_user_id'
os.environ ['USER_IS_ADMIN'] ='1'
os.environ ['AUTH_DOMAIN'] ='todo_auth_domain
os.environ ['FEDERATED_IDENTITY'] ='todo_federated_identity'
os.environ ['FEDERATED_PROVIDER'] ='todo_federated_provider'
您不能 - 用户API仅支持通过API支持的方法登录。如果你想实现自己的登入,您将需要使用第三方会议库,并保持登录用户的常规方式的轨道。
How to create a custom login system with google-app-engine's User class?
I'm making my own login system. I have tried os.environ['USER_EMAIL'] = 'john.doe@example.com'
, but it doesn't work. I guess the information is not saved in a session, so if I visit another page then users.get_current_user() has no memory of what I had set it to previously.
I have seen google-app-engine unit tests that does this to fake a logins. I think these works because the tests are within the same session. I need to store my own custom information across multiple sessions.
I have also tried setting environment variables, but without luck.
os.environ['USER_EMAIL'] = 'john.doe@example.com'
os.environ['USER_ID'] = 'todo_user_id'
os.environ['USER_IS_ADMIN'] = '1'
os.environ['AUTH_DOMAIN'] = 'todo_auth_domain'
os.environ['FEDERATED_IDENTITY'] = 'todo_federated_identity'
os.environ['FEDERATED_PROVIDER'] = 'todo_federated_provider'
You can't - the Users API only supports signing in with methods supported by that API. If you want to implement your own signin, you will need to use a third-party session library and keep track of logged in users the 'regular' way.
这篇关于如何users.set_current_user?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!