Пример #1
0
 def post(self):
     openid = self.get_argument("openid")
     user = User()
     user.whois("qq", openid)
     self.SESSION["uid"] = user._id
     self.SESSION["nick"] = user.nick
     self.write(json.dumps({"ok": "ok"}))
Пример #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
         self.write({"ok": user._id})
     else:
         self.write({"error": "登陆失败"})
Пример #3
0
 def post(self):
     icode = self.get_argument("icode")
     openid = self.get_argument("openid")
     token = self.get_argument("token")
     nick = self.get_argument("nick")
     user = User()
     r = user.qqreg(openid, token, nick=nick)
     if r[0]:
         self.SESSION["uid"] = user._id
         self.SESSION["nick"] = user.nick
         self.write(json.dumps({"ok": "ok"}))
     else:
         self.write(json.dumps({"error": str(r)}))
Пример #4
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/")
Пример #5
0
 def get(self):
     key = self.get_argument("key")
     val = self.get_argument("val")
     d = {}
     if key == "name":
         if User.exist("tel", val):
             d["ok"] = "有效的电话号码"
         else:
             d["error"] = "不存在此电话号码"
     elif key == "qq":
         if User.exist("qq", val):
             d["ok"] = "可登陆QQ号"
         else:
             d["error"] = "尚未绑定,不可用"
     return self.write(json.dumps(d))
Пример #6
0
 def post(self):
     icode = self.get_argument("icode")
     tel = self.get_argument("name")
     password = self.get_argument("password")
     nick = self.get_argument("nick")
     user = User()
     r = user.reg(tel, password, nick=nick)
     if r[0]:
         self.SESSION["uid"] = user._id
         self.SESSION["nick"] = user.nick
         ref = self.request.headers.get("Referer", "").split("/")[-1]
         if ref == "reg":
             ref = "/"
         return self.redirect("/" + ref)
     else:
         return self.redirect("/reg/")
Пример #7
0
 def get(self):
     key = self.get_argument("key")
     val = self.get_argument("val")
     d = {}
     if key == "name":
         if not User.exist("tel", val):
             d["ok"] = "未被注册号码,可用"
         else:
             d["error"] = "该号码已被注册"
     elif key == "icode":
         d["ok"] = "有效的邀请码"
     return self.write(json.dumps(d))