mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-01-08 06:08:10 -05:00
Always persist/read the access token when a keyring isn't available
Otherwise things just silently fail on restart: the users won't be able to sync, and it'll complain about unknown tokens for devices.
This commit is contained in:
parent
70969d43ec
commit
48c7f7a17e
@ -101,6 +101,7 @@ class ProxyDaemon:
|
|||||||
accounts = self.store.load_users(self.name)
|
accounts = self.store.load_users(self.name)
|
||||||
|
|
||||||
for user_id, device_id in accounts:
|
for user_id, device_id in accounts:
|
||||||
|
token = False
|
||||||
if self.conf.keyring:
|
if self.conf.keyring:
|
||||||
try:
|
try:
|
||||||
token = keyring.get_password(
|
token = keyring.get_password(
|
||||||
@ -108,7 +109,7 @@ class ProxyDaemon:
|
|||||||
)
|
)
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
else:
|
if not token:
|
||||||
token = self.store.load_access_token(user_id, device_id)
|
token = self.store.load_access_token(user_id, device_id)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
@ -570,6 +571,7 @@ class ProxyDaemon:
|
|||||||
|
|
||||||
self.pan_clients[user_id] = pan_client
|
self.pan_clients[user_id] = pan_client
|
||||||
|
|
||||||
|
token_stored = False
|
||||||
if self.conf.keyring:
|
if self.conf.keyring:
|
||||||
try:
|
try:
|
||||||
keyring.set_password(
|
keyring.set_password(
|
||||||
@ -577,9 +579,10 @@ class ProxyDaemon:
|
|||||||
f"{user_id}-{pan_client.device_id}-token",
|
f"{user_id}-{pan_client.device_id}-token",
|
||||||
pan_client.access_token,
|
pan_client.access_token,
|
||||||
)
|
)
|
||||||
|
token_stored = True
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
else:
|
if not token_stored:
|
||||||
self.store.save_access_token(
|
self.store.save_access_token(
|
||||||
user_id, pan_client.device_id, pan_client.access_token
|
user_id, pan_client.device_id, pan_client.access_token
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user