Commits

Maciej Sitarz committed b212793

Fixed handling situations when user cancels kwallet dialog or denies access for the app

  • Participants
  • Parent commits 2462fe1

Comments (0)

Files changed (1)

keyring/backends/kwallet.py

         key = username + '@' + service
         network = KWallet.Wallet.NetworkWallet()
         wallet = open_kwallet()
+        if wallet is None:
+            # the user pressed "cancel" when prompted to unlock their keyring.
+            return None
         if wallet.keyDoesNotExist(network, 'Python', key):
             return None
 
         """Set password for the username of the service
         """
         wallet = open_kwallet()
+        if wallet is None:
+            # the user pressed "cancel" when prompted to unlock their keyring.
+            raise PasswordSetError("Cancelled by user")
         wallet.writePassword(username+'@'+service, password)
 
     def delete_password(self, service, username):
         """
         key = username + '@' + service
         wallet = open_kwallet()
+        if wallet is None:
+            # the user pressed "cancel" when prompted to unlock their keyring.
+            raise PasswordDeleteError("Cancelled by user")
         if wallet.keyDoesNotExist(wallet.walletName(), 'Python', key):
             raise PasswordDeleteError("Password not found")
         wallet.removeEntry(key)