Do not replace existing session (#63)
This commit is contained in:
parent
0a2d274824
commit
d2229554a9
|
@ -135,6 +135,11 @@ class Backend:
|
||||||
await client.close()
|
await client.close()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
# Check if the user is already present on mirage
|
||||||
|
if client.user_id in self.clients.keys():
|
||||||
|
await client.logout()
|
||||||
|
return client.user_id
|
||||||
|
|
||||||
if order is None and not self.models["accounts"]:
|
if order is None and not self.models["accounts"]:
|
||||||
order = 0
|
order = 0
|
||||||
elif order is None:
|
elif order is None:
|
||||||
|
|
|
@ -177,6 +177,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
self.profile_task: Optional[asyncio.Future] = None
|
self.profile_task: Optional[asyncio.Future] = None
|
||||||
self.server_config_task: Optional[asyncio.Future] = None
|
self.server_config_task: Optional[asyncio.Future] = None
|
||||||
self.sync_task: Optional[asyncio.Future] = None
|
self.sync_task: Optional[asyncio.Future] = None
|
||||||
|
self.start_task: Optional[asyncio.Future] = None
|
||||||
|
|
||||||
self.upload_monitors: Dict[UUID, nio.TransferMonitor] = {}
|
self.upload_monitors: Dict[UUID, nio.TransferMonitor] = {}
|
||||||
self.upload_tasks: Dict[UUID, asyncio.Task] = {}
|
self.upload_tasks: Dict[UUID, asyncio.Task] = {}
|
||||||
|
@ -236,7 +237,7 @@ class MatrixClient(nio.AsyncClient):
|
||||||
await super().login(
|
await super().login(
|
||||||
password, device_name or self.default_device_name(),
|
password, device_name or self.default_device_name(),
|
||||||
)
|
)
|
||||||
asyncio.ensure_future(self._start())
|
self.start_task = asyncio.ensure_future(self._start())
|
||||||
|
|
||||||
|
|
||||||
async def resume(self, user_id: str, token: str, device_id: str) -> None:
|
async def resume(self, user_id: str, token: str, device_id: str) -> None:
|
||||||
|
@ -245,13 +246,18 @@ class MatrixClient(nio.AsyncClient):
|
||||||
response = nio.LoginResponse(user_id, device_id, token)
|
response = nio.LoginResponse(user_id, device_id, token)
|
||||||
await self.receive_response(response)
|
await self.receive_response(response)
|
||||||
|
|
||||||
asyncio.ensure_future(self._start())
|
self.start_task = asyncio.ensure_future(self._start())
|
||||||
|
|
||||||
|
|
||||||
async def logout(self) -> None:
|
async def logout(self) -> None:
|
||||||
"""Logout from the server. This will delete the device."""
|
"""Logout from the server. This will delete the device."""
|
||||||
|
|
||||||
tasks = (self.profile_task, self.sync_task, self.server_config_task)
|
tasks = (
|
||||||
|
self.profile_task,
|
||||||
|
self.sync_task,
|
||||||
|
self.server_config_task,
|
||||||
|
self.start_task,
|
||||||
|
)
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
if task:
|
if task:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user