mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 07:04:26 +01:00
A api key can always revoke itself, add a route to delete any api key
This commit is contained in:
@@ -53,15 +53,18 @@ namespace BTCPayServer.Security.GreenField
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Remove(string id, string getUserId)
|
||||
public async Task<bool> Remove(string id, string getUserId)
|
||||
{
|
||||
using (var context = _applicationDbContextFactory.CreateContext())
|
||||
{
|
||||
var key = await EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(context.ApiKeys,
|
||||
data => data.Id == id && data.UserId == getUserId);
|
||||
if (key == null)
|
||||
return false;
|
||||
context.ApiKeys.Remove(key);
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public class APIKeyQuery
|
||||
|
||||
Reference in New Issue
Block a user