From ae2726a6ee97f5bf9ec0131c5d5e697cc7d52597 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Fri, 3 May 2024 18:08:04 +0200 Subject: [PATCH] PICARD-2886: If MB server OAuth2 logout fails, show a dialog box Offer the user the options to retry the request, cancel or remove locally stored credentials anyway. This prevents the user being unable to remove local credentials and being stuck with broken credentials due to some technical error. --- picard/ui/options/general.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/picard/ui/options/general.py b/picard/ui/options/general.py index f771dd6fad..8e30c9c61a 100644 --- a/picard/ui/options/general.py +++ b/picard/ui/options/general.py @@ -28,7 +28,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -from PyQt5 import QtCore +from PyQt5 import ( + QtCore, + QtWidgets, +) from picard.config import ( BoolOption, @@ -173,7 +176,27 @@ def logout(self): self.tagger.mb_logout(self.on_logout_finished) def on_logout_finished(self, successful, error_msg=None): - self.update_login_logout(error_msg) + if not successful: + msg = QtWidgets.QMessageBox(self) + msg.setIcon(QtWidgets.QMessageBox.Icon.Warning) + msg.setWindowTitle(_("Logout error")) + msg.setText(_( + "A server error occurred while revoking access to the MusicBrainz server: %s\n" + "\n" + "Remove locally stored credentials anyway?" + ) % error_msg) + msg.setStandardButtons( + QtWidgets.QMessageBox.StandardButton.Yes + | QtWidgets.QMessageBox.StandardButton.No + | QtWidgets.QMessageBox.StandardButton.Retry) + result = msg.exec() + if result == QtWidgets.QMessageBox.StandardButton.Yes: + oauth_manager = self.tagger.webservice.oauth_manager + oauth_manager.forget_access_token() + oauth_manager.forget_refresh_token() + elif result == QtWidgets.QMessageBox.StandardButton.Retry: + self.logout() + self.update_login_logout() def restore_defaults(self): super().restore_defaults()