Exemplo n.º 1
0
 def post(self):
     name = self.get_argument("name")
     password = self.get_argument("password")
     user = User(name=name)
     if user.check_password(password):
         self.SESSION["uid"] = user._id
         self.SESSION["nick"] = user.nick
         self.write({"ok": user._id})
     else:
         self.write({"error": "登陆失败"})
Exemplo n.º 2
0
 def post(self):
     name = self.get_argument("name")
     password = self.get_argument("password")
     user = User(name=name)
     if user.check_password(password):
         self.SESSION["uid"] = user._id
         self.SESSION["nick"] = user.nick
         ref = self.request.headers.get("Referer", "").split("/")[-1]
         if ref == "login":
             ref = "/"
         return self.redirect("/" + ref)
     else:
         print "密码不正确"
         return self.redirect("/login/")