Refactor host user security model, support static assets in modules and themes, module definition permissions and categories, paging control, remove SiteUsers, move seed data from script to site template for installation
This commit is contained in:
@ -4,11 +4,7 @@ using Oqtane.Repository;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Shared;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.IO.Compression;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Controllers
|
||||
{
|
||||
@ -16,58 +12,37 @@ namespace Oqtane.Controllers
|
||||
public class ModuleDefinitionController : Controller
|
||||
{
|
||||
private readonly IModuleDefinitionRepository ModuleDefinitions;
|
||||
private readonly IHostApplicationLifetime HostApplicationLifetime;
|
||||
private readonly IWebHostEnvironment environment;
|
||||
private readonly IInstallation Installation;
|
||||
|
||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IHostApplicationLifetime HostApplicationLifetime, IWebHostEnvironment environment)
|
||||
public ModuleDefinitionController(IModuleDefinitionRepository ModuleDefinitions, IInstallation Installation)
|
||||
{
|
||||
this.ModuleDefinitions = ModuleDefinitions;
|
||||
this.HostApplicationLifetime = HostApplicationLifetime;
|
||||
this.environment = environment;
|
||||
this.Installation = Installation;
|
||||
}
|
||||
|
||||
// GET: api/<controller>
|
||||
[HttpGet]
|
||||
public IEnumerable<ModuleDefinition> Get()
|
||||
public IEnumerable<ModuleDefinition> Get(string siteid)
|
||||
{
|
||||
return ModuleDefinitions.GetModuleDefinitions();
|
||||
return ModuleDefinitions.GetModuleDefinitions(int.Parse(siteid));
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
[HttpPut("{id}")]
|
||||
[Authorize(Roles = Constants.AdminRole)]
|
||||
public void Put(int id, [FromBody] ModuleDefinition ModuleDefinition)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
ModuleDefinitions.UpdateModuleDefinition(ModuleDefinition);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("install")]
|
||||
[Authorize(Roles = Constants.HostRole)]
|
||||
public void InstallModules()
|
||||
{
|
||||
bool install = false;
|
||||
string modulefolder = Path.Combine(environment.WebRootPath, "Modules");
|
||||
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
|
||||
// iterate through module packages
|
||||
foreach (string packagename in Directory.GetFiles(modulefolder, "*.nupkg"))
|
||||
{
|
||||
// iterate through files and deploy to appropriate locations
|
||||
using (ZipArchive archive = ZipFile.OpenRead(packagename))
|
||||
{
|
||||
foreach (ZipArchiveEntry entry in archive.Entries)
|
||||
{
|
||||
string filename = Path.GetFileName(entry.FullName);
|
||||
switch (Path.GetExtension(filename))
|
||||
{
|
||||
case ".dll":
|
||||
entry.ExtractToFile(Path.Combine(binfolder, filename));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove module package
|
||||
System.IO.File.Delete(packagename);
|
||||
install = true;
|
||||
}
|
||||
|
||||
if (install)
|
||||
{
|
||||
// restart application
|
||||
HostApplicationLifetime.StopApplication();
|
||||
}
|
||||
Installation.Install("Modules");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user