本文整理汇总了Python中db.User.by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.by_email方法的具体用法?Python User.by_email怎么用?Python User.by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.by_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import by_email [as 别名]
def post(self):
name = self.get_argument("name", "")
password = self.get_argument("password", "")
email = self.get_argument("email", "")
domain = self.get_argument("domain", "")
password = utils.make_password(password)
if domain == "":
domain = name
if User.by_email(email):
self.redirect("/login") # self.write('用户已经存在,请直接登录')
else:
res = User
res["id"] = res.find().count() + 1
res["user_name"] = name
res["user_pass"] = password
res["user_email"] = email
res["user_domain"] = domain
res.new(res)
send_joinus_email(email, name)
user_info = {
"user_id": res.id,
"user_name": res.user_name,
"user_email": res.user_email,
"user_domain": res.user_domain,
}
self.set_secure_cookie("user", tornado.escape.json_encode(user_info))
self.redirect(self.get_argument("next", "/"))
示例2: get
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import by_email [as 别名]
def get(self):
if self.get_argument("openid.mode", None):
user = yield self.get_authenticated_user()
doc = User.by_email(user["email"])
if not doc:
doc = User
doc["id"] = doc.find().count() + 1
doc["user_name"] = user["name"]
doc["user_pass"] = utils.make_emailverify()
doc["user_email"] = user["email"]
doc["user_domain"] = user["name"]
doc.new(doc)
send_joinus_email(user["email"], user["name"])
user_info = {
"user_id": doc.id,
"user_name": doc.user_name,
"user_email": doc.user_email,
"user_domain": doc.user_domain,
}
self.set_secure_cookie("user", tornado.escape.json_encode(user_info))
self.redirect("/")
return
self.authenticate_redirect()