only allow download of assemblies when using WebAssembly
This commit is contained in:
parent
768066db58
commit
e92d34a9e3
|
@ -30,11 +30,12 @@ namespace Oqtane.Controllers
|
||||||
private readonly IMemoryCache _cache;
|
private readonly IMemoryCache _cache;
|
||||||
private readonly IHttpContextAccessor _accessor;
|
private readonly IHttpContextAccessor _accessor;
|
||||||
private readonly IAliasRepository _aliases;
|
private readonly IAliasRepository _aliases;
|
||||||
|
private readonly ISiteRepository _sites;
|
||||||
private readonly ILogger<InstallationController> _filelogger;
|
private readonly ILogger<InstallationController> _filelogger;
|
||||||
private readonly ITenantManager _tenantManager;
|
private readonly ITenantManager _tenantManager;
|
||||||
private readonly IServerStateManager _serverState;
|
private readonly IServerStateManager _serverState;
|
||||||
|
|
||||||
public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases, ILogger<InstallationController> filelogger, ITenantManager tenantManager, IServerStateManager serverState)
|
public InstallationController(IConfigManager configManager, IInstallationManager installationManager, IDatabaseManager databaseManager, ILocalizationManager localizationManager, IMemoryCache cache, IHttpContextAccessor accessor, IAliasRepository aliases, ISiteRepository sites, ILogger<InstallationController> filelogger, ITenantManager tenantManager, IServerStateManager serverState)
|
||||||
{
|
{
|
||||||
_configManager = configManager;
|
_configManager = configManager;
|
||||||
_installationManager = installationManager;
|
_installationManager = installationManager;
|
||||||
|
@ -43,6 +44,7 @@ namespace Oqtane.Controllers
|
||||||
_cache = cache;
|
_cache = cache;
|
||||||
_accessor = accessor;
|
_accessor = accessor;
|
||||||
_aliases = aliases;
|
_aliases = aliases;
|
||||||
|
_sites = sites;
|
||||||
_filelogger = filelogger;
|
_filelogger = filelogger;
|
||||||
_tenantManager = tenantManager;
|
_tenantManager = tenantManager;
|
||||||
_serverState = serverState;
|
_serverState = serverState;
|
||||||
|
@ -104,16 +106,34 @@ namespace Oqtane.Controllers
|
||||||
// GET api/<controller>/list
|
// GET api/<controller>/list
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
public List<string> List()
|
public List<string> List()
|
||||||
|
{
|
||||||
|
var alias = _tenantManager.GetAlias();
|
||||||
|
var site = _sites.GetSite(alias.SiteId);
|
||||||
|
if (site != null && site.Runtime == "WebAssembly")
|
||||||
{
|
{
|
||||||
return GetAssemblyList().Select(item => item.HashedName).ToList();
|
return GetAssemblyList().Select(item => item.HashedName).ToList();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// GET api/<controller>/load?list=x,y
|
// GET api/<controller>/load?list=x,y
|
||||||
[HttpGet("load")]
|
[HttpGet("load")]
|
||||||
public IActionResult Load(string list = "*")
|
public IActionResult Load(string list = "*")
|
||||||
|
{
|
||||||
|
var alias = _tenantManager.GetAlias();
|
||||||
|
var site = _sites.GetSite(alias.SiteId);
|
||||||
|
if (site != null && site.Runtime == "WebAssembly")
|
||||||
{
|
{
|
||||||
return File(GetAssemblies(list), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll");
|
return File(GetAssemblies(list), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return File(GetEmptyZip(), System.Net.Mime.MediaTypeNames.Application.Octet, "oqtane.dll");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<ClientAssembly> GetAssemblyList()
|
private List<ClientAssembly> GetAssemblyList()
|
||||||
{
|
{
|
||||||
|
@ -238,6 +258,18 @@ namespace Oqtane.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] GetEmptyZip()
|
||||||
|
{
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var zip = new ZipArchive(stream, ZipArchiveMode.Create))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task RegisterContact(string email)
|
private async Task RegisterContact(string email)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue
Block a user