From 54c772d3ac1926c2da594ec3b3b4507faf2d7aa9 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Mon, 9 May 2022 03:29:48 -0400 Subject: [PATCH] "login" command: Don't delete saved password when using it --- matrix_appservice_kakaotalk/commands/auth.py | 29 ++++++++++---------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/matrix_appservice_kakaotalk/commands/auth.py b/matrix_appservice_kakaotalk/commands/auth.py index 6b76e62..e604881 100644 --- a/matrix_appservice_kakaotalk/commands/auth.py +++ b/matrix_appservice_kakaotalk/commands/auth.py @@ -78,6 +78,21 @@ async def login(evt: CommandEvent) -> None: email = evt.args[0 if not save else 1] if num_args > 0 else None if email: + try: + creds = await LoginCredential.get_by_mxid(evt.sender.mxid) + except: + evt.log.exception("Exception while looking for saved password") + creds = None + if creds and creds.email == email: + await evt.reply("Logging in with saved password") + evt.sender.command_status = { + "action": "Login with saved password", + "room_id": evt.room_id, + "save": True, + } + await _login_with_password(evt, email, creds.password, evt.sender.force_login) + return + evt.sender.command_status = { "action": "Login", "room_id": evt.room_id, @@ -86,20 +101,6 @@ async def login(evt: CommandEvent) -> None: "save": save, "forced": evt.sender.force_login, } - try: - creds = await LoginCredential.get_by_mxid(evt.sender.mxid) - except: - evt.log.exception("Exception while looking for saved password") - creds = None - if creds and creds.email == email: - await evt.reply("Logging in with saved password") - await _login_with_password( - evt, - evt.sender.command_status.pop("email"), - creds.password, - evt.sender.command_status.pop("forced"), - ) - return """ TODO Implement web login if evt.bridge.public_website: