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:
Shaun Walker
2019-09-19 16:33:48 -04:00
parent 35b9b9e89b
commit 83a212e7e3
61 changed files with 1000 additions and 979 deletions

View File

@ -3,12 +3,8 @@ using Microsoft.AspNetCore.Mvc;
using Oqtane.Repository;
using Oqtane.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Hosting;
using Oqtane.Shared;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using System.Reflection;
using System.IO.Compression;
using Oqtane.Infrastructure;
namespace Oqtane.Controllers
{
@ -16,14 +12,12 @@ namespace Oqtane.Controllers
public class ThemeController : Controller
{
private readonly IThemeRepository Themes;
private readonly IHostApplicationLifetime HostApplicationLifetime;
private readonly IWebHostEnvironment environment;
private readonly IInstallation Installation;
public ThemeController(IThemeRepository Themes, IHostApplicationLifetime HostApplicationLifetime, IWebHostEnvironment environment)
public ThemeController(IThemeRepository Themes, IInstallation Installation)
{
this.Themes = Themes;
this.HostApplicationLifetime = HostApplicationLifetime;
this.environment = environment;
this.Installation = Installation;
}
// GET: api/<controller>
@ -37,37 +31,7 @@ namespace Oqtane.Controllers
[Authorize(Roles = Constants.HostRole)]
public void InstallThemes()
{
bool install = false;
string themefolder = Path.Combine(environment.WebRootPath, "Themes");
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
// iterate through theme packages
foreach (string packagename in Directory.GetFiles(themefolder, "*.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 theme package
System.IO.File.Delete(packagename);
install = true;
}
if (install)
{
// restart application
HostApplicationLifetime.StopApplication();
}
Installation.Install("Themes");
}
}
}