Exemplo n.º 1
0
    def POST(self):
        usercode =  web.ctx.env.get("HTTP_X_COPYPASTA_CODE")

        if usercode:

            split = usercode.split("&")
            user = split[0].split("=")[1]
            code = split[1].split("=")[1]

            if user:
                userinfo = userdb.select('users', where='user=$user', vars=locals())
                userinfo = userinfo[0]
                salt = userinfo.password

                hashed_secretcode = hashlib.sha512(code + salt).hexdigest()

                if hashed_secretcode == userinfo.secretcode:
                    id = web.data()
                    print id;
                    if id:
                        model.del_clip(int(id), getuser())

                        web.header('Content-Type', 'application/json')
                        dict = {'status':"Clip deleted"}
                        return json.dumps(dict)
                    else:
                        dict = {'status':"Bad id"}
                        web.header('Content-Type', 'application/json')
                        return json.dumps(dict)
                else:
                    dict = {'status':"Bad login"}
                    web.header('Content-Type', 'application/json')
                    return json.dumps(dict)
            else:
                dict = {'status':"Invalid user"}
                web.header('Content-Type', 'application/json')
                return json.dumps(dict)
        else:
            raise web.seeother('/')
Exemplo n.º 2
0
 def POST(self, id):
     model.del_clip(int(id), getuser())
     raise web.seeother('/')