Skip to content

Commit

Permalink
Push bad credentials state if session isn't valid in start()
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 20, 2021
1 parent e4a2bd2 commit 8865dab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mautrix_telegram/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
BridgeState.human_readable_errors.update({
"tg-not-connected": "Your Telegram connection failed",
"tg-auth-key-duplicated": "The bridge accidentally logged you out",
"tg-not-authenticated": "The stored auth token did not work",
})


Expand Down Expand Up @@ -228,6 +229,9 @@ async def start(self, delete_unless_authenticated: bool = False) -> 'User':
elif delete_unless_authenticated:
self.log.debug(f"Unauthenticated user {self.name} start()ed, deleting session...")
await self.client.disconnect()
if self.tgid:
await self.push_bridge_state(BridgeStateEvent.BAD_CREDENTIALS,
error="tg-not-authenticated")
self.client.session.delete()
return self

Expand Down Expand Up @@ -366,7 +370,6 @@ async def update_info(self, info: TLUser = None) -> None:
self.by_tgid[self.tgid] = self
if changed:
await self.save()
return info

async def log_out(self) -> bool:
puppet = pu.Puppet.get(self.tgid)
Expand Down

0 comments on commit 8865dab

Please sign in to comment.