feat: only delete if the secret is present in the keychain

This commit is contained in:
James Houlahan
2021-01-05 09:51:13 +01:00
parent e50d1d01da
commit 5380edeeb9

View File

@ -102,10 +102,19 @@ func (kc *Keychain) List() ([]string, error) {
return userIDs, nil
}
func (kc *Keychain) Delete(userID string) (err error) {
func (kc *Keychain) Delete(userID string) error {
kc.locker.Lock()
defer kc.locker.Unlock()
userIDsByURL, err := kc.helper.List()
if err != nil {
return err
}
if _, ok := userIDsByURL[kc.secretURL(userID)]; !ok {
return nil
}
return kc.helper.Delete(kc.secretURL(userID))
}