Skip to content

Commit

Permalink
PICARD-2886: If MB server OAuth2 logout fails, show a dialog box
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phw committed Dec 8, 2024
1 parent 9308f44 commit e594e31
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions picard/ui/options/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e594e31

Please sign in to comment.