update cookie after editing a comment
This commit is contained in:
parent
423782d75b
commit
6242d243c9
@ -95,8 +95,7 @@ def new(app, environ, request, uri):
|
|||||||
|
|
||||||
resp = Response(json.dumps(rv), 202 if rv["mode"] == 2 else 201,
|
resp = Response(json.dumps(rv), 202 if rv["mode"] == 2 else 201,
|
||||||
content_type='application/json')
|
content_type='application/json')
|
||||||
resp.set_cookie(str(rv["id"]), app.sign([rv["id"], checksum]),
|
resp.set_cookie(str(rv["id"]), app.sign([rv["id"], checksum]), max_age=app.MAX_AGE)
|
||||||
max_age=app.MAX_AGE, path='/')
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
@ -153,8 +152,12 @@ def single(app, environ, request, id):
|
|||||||
for key in set(rv.keys()) - FIELDS:
|
for key in set(rv.keys()) - FIELDS:
|
||||||
rv.pop(key)
|
rv.pop(key)
|
||||||
|
|
||||||
|
checksum = hashlib.md5(rv["text"]).hexdigest()
|
||||||
rv["text"] = app.markdown(rv["text"])
|
rv["text"] = app.markdown(rv["text"])
|
||||||
return Response(json.dumps(rv), 200, content_type='application/json')
|
|
||||||
|
resp = Response(json.dumps(rv), 200, content_type='application/json')
|
||||||
|
resp.set_cookie(str(rv["id"]), app.sign([rv["id"], checksum]), max_age=app.MAX_AGE)
|
||||||
|
return resp
|
||||||
|
|
||||||
if request.method == 'DELETE':
|
if request.method == 'DELETE':
|
||||||
|
|
||||||
|
@ -236,3 +236,12 @@ class TestComments(unittest.TestCase):
|
|||||||
|
|
||||||
rv = self.get('/count?uri=%2Fpath%2F')
|
rv = self.get('/count?uri=%2Fpath%2F')
|
||||||
assert rv.status_code == 404
|
assert rv.status_code == 404
|
||||||
|
|
||||||
|
def testModify(self):
|
||||||
|
self.post('/new?uri=test', data=json.dumps({"text": "Tpyo"}))
|
||||||
|
|
||||||
|
self.put('/id/1', data=json.dumps({"text": "Tyop"}))
|
||||||
|
assert json.loads(self.get('/id/1').data)["text"] == "<p>Tyop</p>\n"
|
||||||
|
|
||||||
|
self.put('/id/1', data=json.dumps({"text": "Typo"}))
|
||||||
|
assert json.loads(self.get('/id/1').data)["text"] == "<p>Typo</p>\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user