Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Merge pull request #3008 from gratipay/fix-js-sign-out
Browse files Browse the repository at this point in the history
Fix JS sign-out
  • Loading branch information
techtonik committed Dec 14, 2014
2 parents 94d83ad + 68af1a9 commit 54a82b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/py/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def test_sign_out_overwrites_session_cookie(self):
assert response.code == 302
assert response.headers.cookie[SESSION].value == ''

def test_sign_out_doesnt_redirect_xhr(self):
self.make_participant('alice')
response = self.client.PxST('/sign-out.html', auth_as='alice',
HTTP_X_REQUESTED_WITH=b'XMLHttpRequest')
assert response.code == 200

def test_receipts_signed_in(self):
self.make_participant('alice', claimed_time='now')
self.db.run("INSERT INTO exchanges (id, participant, amount, fee) "
Expand Down
3 changes: 3 additions & 0 deletions www/sign-out.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if user.ANON:
if POST:
user.sign_out(response.headers.cookie)

if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
raise Response(200)

if 'back_to' in request.body:
back_to = request.body['back_to']
else:
Expand Down

0 comments on commit 54a82b5

Please sign in to comment.