Commit 75f35fd2 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

When receiving singleton credential, remove all other instances

Before 42a3acc2, more than one instance of the singleton credential type may have been stored.
parent 1b853dc0
......@@ -224,8 +224,10 @@ func (client *Client) addCredential(cred *credential, storeAttributes bool) (err
}
// If this is a singleton credential type, ensure we have at most one by removing any previous instance
if !id.Empty() && cred.CredentialType().IsSingleton && len(client.attrs(id)) > 0 {
client.remove(id, 0, false) // Index is 0, because if we're here we have exactly one
if !id.Empty() && cred.CredentialType().IsSingleton {
for len(client.attrs(id)) != 0 {
client.remove(id, 0, false)
}
}
// Append the new cred to our attributes and credentials
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment