1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Finished work on secrets views; removed path from cookie assignment

This commit is contained in:
Jeremy Stretch
2017-03-21 15:30:36 -04:00
parent 5c4741c5d4
commit 6d30fdb83d
3 changed files with 28 additions and 19 deletions

View File

@ -169,6 +169,9 @@ class GetSessionKeyViewSet(ViewSet):
sk = SessionKey(userkey=user_key)
sk.save(master_key=master_key)
encoded_key = base64.b64encode(sk.key)
# b64decode() returns a bytestring under Python 3
if not isinstance(encoded_key, str):
encoded_key = encoded_key.decode()
# Craft the response
response = Response({
@ -177,7 +180,7 @@ class GetSessionKeyViewSet(ViewSet):
# If token authentication is not in use, assign the session key as a cookie
if request.auth is None:
response.set_cookie('session_key', value=encoded_key, path=reverse('secrets-api:secret-list'))
response.set_cookie('session_key', value=encoded_key)
return response