Skip to content

Commit

Permalink
feat: remove
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobritodev committed Aug 26, 2022
1 parent b8ee8c4 commit dea26ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/NetDevPack.Fido2.EntityFramework.Store/Store/Fido2Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,28 @@ public Task<List<StoredCredentialDetail>> ListCredentialDetailsByUser(string use
{
return _context.Fido2StoredCredential.AsNoTrackingWithIdentityResolution().Where(w => w.Username == username.ToLower().Trim()).ToListAsync();
}

public async Task<bool> RemoveByPublicKeyId(byte[] publicKeyId)
{
var key = await _context.Fido2StoredCredential.FirstOrDefaultAsync(f => f.PublicKeyId == publicKeyId);
if (key is not null)
{
_context.Fido2StoredCredential.Remove(key);
return _context.SaveChanges() > 0;
}

return false;
}

public async Task<bool> RemoveBySecretName(string name)
{
var key = await _context.Fido2StoredCredential.FirstOrDefaultAsync(f => f.SecurityKeyName == name);
if (key is not null)
{
_context.Fido2StoredCredential.Remove(key);
return _context.SaveChanges() > 0;
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public interface IFido2Store
Task<string?> GetUsernameByIdAsync(byte[] userId);
Task<List<StoredCredentialDetail>> ListCredentialDetailsByUser(byte[] userId);
Task<List<StoredCredentialDetail>> ListCredentialDetailsByUser(string username);
Task<bool> RemoveByPublicKeyId(byte[] publicKeyId);
Task<bool> RemoveBySecretName(string name);
}

0 comments on commit dea26ce

Please sign in to comment.