Skip to content

Commit

Permalink
Fix return type of KWallet get_credential()
Browse files Browse the repository at this point in the history
Docs:
get_credential(service, username): Return a credential object stored in
the active keyring. This object contains at least username and password
attributes for the specified service, where the returned username may be
different from the argument.

Prior to this commit, get_credential() returned the password as a string,
without wrapping the credential into a SimpleCredential object.
  • Loading branch information
MrAnno committed Sep 1, 2020
1 parent c0ec24c commit 4d48913
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion keyring/backends/kwallet.py
Expand Up @@ -123,7 +123,8 @@ def get_credential(self, service, username):
Otherwise, it will return the first username and password combo that it finds.
"""
if username is not None:
return self.get_password(service, username)
return super().get_credential(service, username)

if not self.connected(service):
# the user pressed "cancel" when prompted to unlock their keyring.
raise KeyringLocked("Failed to unlock the keyring!")
Expand All @@ -134,6 +135,8 @@ def get_credential(self, service, username):
)
return SimpleCredential(str(username), str(password))

return None

def set_password(self, service, username, password):
"""Set password for the username of the service"""
if not self.connected(service):
Expand Down

0 comments on commit 4d48913

Please sign in to comment.