本文整理匯總了Python中database.User.verify_user方法的典型用法代碼示例。如果您正苦於以下問題:Python User.verify_user方法的具體用法?Python User.verify_user怎麽用?Python User.verify_user使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類database.User
的用法示例。
在下文中一共展示了User.verify_user方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: post
# 需要導入模塊: from database import User [as 別名]
# 或者: from database.User import verify_user [as 別名]
def post(self):
if self.get_argument("username", default=None) is None:
# TODO Check whether username is exist
username = "GUEST_" + hashlib.md5(str(time.time()) + str(random())).hexdigest()[0:8]
password = hashlib.md5(str(time.time()) + str(random())).hexdigest()
user = User.new(username=username, password=hashlib.md5(password).hexdigest())
user.screen_name = username.replace("GUEST_", u"遊客")[0:6]
else:
username = self.get_argument("username")
password = hashlib.md5(self.get_argument("password")).hexdigest()
user = User.verify_user(username, password)
if user is None:
message = {"status": "failed", "content": "invalid username or password"}
else:
message = {"status": "success", "username": user.username, "password": password}
self.session["user_id"] = user.id
if user.last_login == None:
user.bonus_notification = 1
else:
last_login_date = datetime.fromtimestamp(user.last_login)
if last_login_date.date() < datetime.today().date():
user.bonus_notification = 1
user.last_login = int(time.time())
self.set_header("Access-Control-Allow-Origin", "*")
self.write(json.dumps(message))