feat: only delete if the secret is present in the keychain
This commit is contained in:
@ -102,10 +102,19 @@ func (kc *Keychain) List() ([]string, error) {
|
|||||||
return userIDs, nil
|
return userIDs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kc *Keychain) Delete(userID string) (err error) {
|
func (kc *Keychain) Delete(userID string) error {
|
||||||
kc.locker.Lock()
|
kc.locker.Lock()
|
||||||
defer kc.locker.Unlock()
|
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))
|
return kc.helper.Delete(kc.secretURL(userID))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user