From 0e34a3b1965aef2503ad3eb9d7bff124745ca5ae Mon Sep 17 00:00:00 2001 From: knotteye Date: Sun, 25 Apr 2021 16:03:55 -0500 Subject: [PATCH] Handle cases of bad login info --- plchat.py | 10 +++++++++- pleroma.py | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plchat.py b/plchat.py index ee17d63..06d4f1e 100644 --- a/plchat.py +++ b/plchat.py @@ -288,6 +288,10 @@ class App(QMainWindow): # Returns username, instance return self.acctComboBox.currentText().split('@')[1], self.acctComboBox.currentText().split('@')[2] + def badLogin(self, name): + self.Err.showMessage("Bad login info for: "+name) + self.newAcctDialog() + def newAcctDialog(self): dialog = LoginDialog(self) dialog.getInput(self.initAcct) @@ -1403,7 +1407,11 @@ class RegisterThread(threading.Thread): def run(self): self.acct.register() - self.acct.login() + try: + self.acct.login() + except ValueError: + ex._eventloop.call_soon_threadsafe(ex.badLogin, self.acct.username+'@'+self.acct.instance) + return NotifThread(self.acct).start() self.acct.setChatUpdate(ex.handlePleromaEvent) self.callback(self.acct) diff --git a/pleroma.py b/pleroma.py index 455d3c7..306dd61 100644 --- a/pleroma.py +++ b/pleroma.py @@ -94,6 +94,8 @@ class Account(): 'challenge_type': code_type, 'code': mfa_code }) + elif 'error' in response: + raise ValueError self.token = response['access_token'] self.refresh_token = response['refresh_token'] r = self.apiRequest('GET', '/api/v1/accounts/verify_credentials')