Ejemplo n.º 1
0
 def post_account_setting(self, x):
     keys = x.keys()
     if "email" in keys:
         email = x.email
         if email.strip():
             userid = web.ctx.session.userid
             try:
                 xss_db.update("user", where="id=$userid", name=email, email=email, vars=locals())
             except Exception as error:
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             web.ctx.session.email = email
     if "oldpass" in keys and "newpass" in keys and "confirmpass" in keys:
         passwd = (x.oldpass).strip()
         newpasswd = (x.newpass).strip()
         confirmpasswd = (x.confirmpass).strip()
         if passwd and newpasswd and confirmpasswd:
             pwhash = hashlib.md5(passwd).hexdigest()
             result = xss_db.query(
                 "select count(*) as count from user where id=$userid and pwhash=$pwhash",
                 vars={"userid": web.ctx.session.userid, "pwhash": pwhash},
             )
             if not result[0].count == 1:
                 error = "passwd is error"
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             if not newpasswd == confirmpasswd:
                 error = u"两次输入的密码不相同"
                 return utils.json_response(205, str(error))
             web.ctx.session.user = email
             try:
                 xss_db.update("user", where="id=$userid", pwhash=pwhash, vars=locals())
             except Exception as error:
                 return utils.json_response(205, str(error))
     return utils.json_response(204)
Ejemplo n.º 2
0
 def GET(self):
     x = web.input()
     print x
     result = xss_db.query('select sendtime, past from user where id=$userid', 
             vars={'userid': web.ctx.session.userid}
             )
     t = result[0]
     sendtime = t.sendtime
     past = t.past
     print sendtime, past
     return render.settings(sendtime=sendtime, past=past)
Ejemplo n.º 3
0
 def get_docustatus(self, x):
     if "userid" not in x.keys():
         userid = web.ctx.session.userid
     else:
         userid = x.userid
     print userid
     d = {}
     result = xss_db.query("select count(*) as count from docu where userid=$userid", vars={"userid": userid})
     print result
     d["total"] = result[0].count
     return json.dumps(d)