Greenfield: Resolve store user's image URL

Amendment to #6427.
This commit is contained in:
Dennis Reimann
2024-12-15 10:02:13 +01:00
parent 7829a93251
commit fe3bccf3ce

View File

@@ -1,11 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Abstractions.Constants; using BTCPayServer.Abstractions.Constants;
using BTCPayServer.Abstractions.Extensions; using BTCPayServer.Abstractions.Extensions;
using BTCPayServer.Client; using BTCPayServer.Client;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Services;
using BTCPayServer.Services.Stores; using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
@@ -22,11 +22,16 @@ namespace BTCPayServer.Controllers.Greenfield
{ {
private readonly StoreRepository _storeRepository; private readonly StoreRepository _storeRepository;
private readonly UserManager<ApplicationUser> _userManager; private readonly UserManager<ApplicationUser> _userManager;
private readonly UriResolver _uriResolver;
public GreenfieldStoreUsersController(StoreRepository storeRepository, UserManager<ApplicationUser> userManager) public GreenfieldStoreUsersController(
StoreRepository storeRepository,
UserManager<ApplicationUser> userManager,
UriResolver uriResolver)
{ {
_storeRepository = storeRepository; _storeRepository = storeRepository;
_userManager = userManager; _userManager = userManager;
_uriResolver = uriResolver;
} }
[Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)] [Authorize(Policy = Policies.CanViewStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
@@ -95,8 +100,7 @@ namespace BTCPayServer.Controllers.Greenfield
Role = storeUser.StoreRoleId, Role = storeUser.StoreRoleId,
Email = user?.Email, Email = user?.Email,
Name = blob?.Name, Name = blob?.Name,
ImageUrl = blob?.ImageUrl, ImageUrl = blob?.ImageUrl == null ? null : await _uriResolver.Resolve(Request.GetAbsoluteRootUri(), UnresolvedUri.Create(blob.ImageUrl))
}); });
} }
return storeUsers; return storeUsers;