Fix Session not being able to save auth_key=None

This commit is contained in:
Lonami Exo 2017-06-08 16:45:09 +02:00
parent d788d30de2
commit 6a043b7371

View File

@ -123,7 +123,8 @@ class JsonSession:
'time_offset': self.time_offset,
'server_address': self.server_address,
'auth_key_data':
b64encode(self.auth_key.key).decode('ascii')
b64encode(self.auth_key.key).decode('ascii')\
if self.auth_key else None
}, file)
def delete(self):
@ -160,6 +161,7 @@ class JsonSession:
# FIXME We need to import the AuthKey here or otherwise
# we get cyclic dependencies.
from ..crypto import AuthKey
if data['auth_key_data'] is not None:
key = b64decode(data['auth_key_data'])
result.auth_key = AuthKey(data=key)