Delete session on log_out() even if telegram logout fails

This commit is contained in:
Tulir Asokan
2021-10-20 20:24:47 +03:00
parent 8865dab6b0
commit 4e8c373d1b
2 changed files with 3 additions and 4 deletions
+2 -3
View File
@@ -398,12 +398,11 @@ class User(AbstractUser, BaseUser):
self.tgid = None self.tgid = None
await self.save() await self.save()
ok = await self.client.log_out() ok = await self.client.log_out()
if not ok: self.client.session.delete()
return False
self.delete() self.delete()
await self.stop() await self.stop()
self._track_metric(METRIC_LOGGED_IN, False) self._track_metric(METRIC_LOGGED_IN, False)
return True return ok
def _search_local(self, query: str, max_results: int = 5, min_similarity: int = 45 def _search_local(self, query: str, max_results: int = 5, min_similarity: int = 45
) -> List[SearchResult]: ) -> List[SearchResult]:
@@ -465,7 +465,7 @@ class ProvisioningAPI(AuthAPI):
Optional[web.Response]]): Optional[web.Response]]):
err = self.check_authorization(request) err = self.check_authorization(request)
if err is not None: if err is not None:
return err return None, None, err
data = None data = None
if want_data and (request.method == "POST" or request.method == "PUT"): if want_data and (request.method == "POST" or request.method == "PUT"):