Revoke Legacy Api Keys (#1344)

closes #1333
This commit is contained in:
Andrew Camilleri
2020-02-21 05:40:00 +01:00
committed by GitHub
parent b79b310bd5
commit 34702d2633
3 changed files with 46 additions and 5 deletions

View File

@@ -76,6 +76,21 @@ namespace BTCPayServer.Security.Bitpay
}
}
public async Task RevokeLegacyAPIKeys(string storeId)
{
var keys = await GetLegacyAPIKeys(storeId);
if (!keys.Any())
{
return;
}
using (var ctx = _Factory.CreateContext())
{
ctx.ApiKeys.RemoveRange(keys.Select(s => new APIKeyData() {Id = s}));
await ctx.SaveChangesAsync();
}
}
public async Task<string[]> GetLegacyAPIKeys(string storeId)
{
using (var ctx = _Factory.CreateContext())