mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
[Greenfield] Allow passing email instead of user id in API (#4732)
This commit is contained in:
@@ -20,10 +20,12 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
public class GreenfieldStoreUsersController : ControllerBase
|
||||
{
|
||||
private readonly StoreRepository _storeRepository;
|
||||
private readonly UserManager<ApplicationUser> _userManager;
|
||||
|
||||
public GreenfieldStoreUsersController(StoreRepository storeRepository, UserManager<ApplicationUser> userManager)
|
||||
{
|
||||
_storeRepository = storeRepository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpGet("~/api/v1/stores/{storeId}/users")]
|
||||
@@ -34,8 +36,8 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
return store == null ? StoreNotFound() : Ok(FromModel(store));
|
||||
}
|
||||
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/users/{userId}")]
|
||||
public async Task<IActionResult> RemoveStoreUser(string storeId, string userId)
|
||||
[HttpDelete("~/api/v1/stores/{storeId}/users/{idOrEmail}")]
|
||||
public async Task<IActionResult> RemoveStoreUser(string storeId, string idOrEmail)
|
||||
{
|
||||
var store = HttpContext.GetStoreData();
|
||||
if (store == null)
|
||||
@@ -43,9 +45,9 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
return StoreNotFound();
|
||||
}
|
||||
|
||||
if (await _storeRepository.RemoveStoreUser(storeId, userId))
|
||||
var userId = await _userManager.FindByIdOrEmail(idOrEmail);
|
||||
if (userId != null && await _storeRepository.RemoveStoreUser(storeId, idOrEmail))
|
||||
{
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user