Пример #1
0
 def post(self):
     title = self.get_argument("title", "i have a dream")
     content = self.get_argument("content", "i have a dream")
     tags = self.get_argument("tags", "dream,")
     eMail = email = self.get_secure_cookie('usereMail')
     user = BlogUser.get(BlogUser.email==eMail)
     dream = BlogDream.create(title=title, content=content, user=user)
     model.saveTag(tags, dream.id)
     self.redirect("/dream/id/"+str(dream.id))
Пример #2
0
 def get_current_user(self):
     email = self.get_secure_cookie('usereMail')
     if not email:
         return None
     else:
         try:
             user = BlogUser.get(BlogUser.email == email)
         except DoesNotExist:
             self.clear_cookie('usereMail')
         return user
Пример #3
0
 def post(self, *args, **kwargs):
     eMail = self.get_argument("email", "")
     pswd = self.get_argument("pswd", "")
     print eMail
     print pswd
     # 验证用户名和密码
     # if eMail.startswith("liwq"):
     blogUser = BlogUser.select().where(BlogUser.email==eMail, BlogUser.password==pswd)
     if blogUser.count() == 1:
         self.set_secure_cookie("usereMail", str(eMail))
         # print "eMail is %s" %(str(eMail))
         self.redirect(self.get_argument("next", "/"))
     else:
         self.write("<script>alert('用户密码不存在');history.back();</script>")