本文整理汇总了Python中db.User.by_email_pass方法的典型用法代码示例。如果您正苦于以下问题:Python User.by_email_pass方法的具体用法?Python User.by_email_pass怎么用?Python User.by_email_pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.User
的用法示例。
在下文中一共展示了User.by_email_pass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import by_email_pass [as 别名]
def post(self):
email = self.get_argument("email", '')
password = self.get_argument("password", '')
password = hashlib.md5(password).hexdigest()
res = User.by_email_pass(email, password)
if res:
user = {'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))
self.redirect(self.get_argument("next", "/"))
else:
self.write('密码错误或用户不存在,请重新注册或登录')
示例2: post
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import by_email_pass [as 别名]
def post(self):
email = self.get_argument("email", "")
password = self.get_argument("password", "")
password = utils.make_password(password)
doc = User.by_email_pass(email, password)
if doc:
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(self.get_argument("next", "/"))
return
self.redirect("/login") # self.write('密码错误或用户不存在,请重新注册或登录')
示例3: post
# 需要导入模块: from db import User [as 别名]
# 或者: from db.User import by_email_pass [as 别名]
def post(self):
email = self.get_argument('email', '')
password = self.get_argument('password', '')
password = utils.make_password(password)
doc = User.by_email_pass(email, password)
if doc:
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(self.get_argument('next', '/'))
return
self.authenticate_redirect()