fixed issues when running on WebAssembly, made IModule implementations consistent

This commit is contained in:
Shaun Walker 2020-04-06 13:25:19 -04:00
parent 898bf38156
commit 7421df2970
8 changed files with 35 additions and 18 deletions

View File

@ -2,7 +2,7 @@
namespace Oqtane.Modules.Admin.ModuleCreator
{
public class Module : IModule
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{

View File

@ -3,7 +3,7 @@ using Oqtane.Modules;
namespace Oqtane.Modules.[Module]s
{
public class Module : IModule
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{

View File

@ -2,7 +2,7 @@
namespace Oqtane.Modules.Counter
{
public class Module : IModule
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{

View File

@ -2,7 +2,7 @@
namespace Oqtane.Modules.Weather
{
public class Module : IModule
public class ModuleInfo : IModule
{
public ModuleDefinition ModuleDefinition => new ModuleDefinition
{

View File

@ -20,6 +20,7 @@ namespace Oqtane.Client
builder.RootComponents.Add<App>("app");
builder.Services.AddBaseAddressHttpClient();
builder.Services.AddOptions();
// register auth services
builder.Services.AddAuthorizationCore();

View File

@ -122,13 +122,22 @@ namespace Oqtane.Controllers
}
}
// GET api/<controller>/load/filename
[HttpGet("load/{filename}")]
// GET api/<controller>/load/assembyname
[HttpGet("load/{assemblyname}")]
public IActionResult Load(string assemblyname)
{
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, assemblyname));
return File(file, "application/octet-stream", assemblyname);
if (Path.GetExtension(assemblyname).ToLower() == ".dll")
{
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, assemblyname));
return File(file, "application/octet-stream", assemblyname);
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Download Assembly {Assembly}", assemblyname);
HttpContext.Response.StatusCode = 401;
return null;
}
}
// POST api/<controller>?moduleid=x

View File

@ -75,13 +75,23 @@ namespace Oqtane.Controllers
}
}
// GET api/<controller>/load/filename
[HttpGet("load/{filename}")]
public IActionResult Load(string filename)
// GET api/<controller>/load/assembyname
[HttpGet("load/{assemblyname}")]
public IActionResult Load(string assemblyname)
{
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, filename));
return File(file, "application/octet-stream", filename);
if (Path.GetExtension(assemblyname).ToLower() == ".dll")
{
string binfolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
byte[] file = System.IO.File.ReadAllBytes(Path.Combine(binfolder, assemblyname));
return File(file, "application/octet-stream", assemblyname);
}
else
{
_logger.Log(LogLevel.Error, this, LogFunction.Read, "User Not Authorized To Download Assembly {Assembly}", assemblyname);
HttpContext.Response.StatusCode = 401;
return null;
}
}
}
}

View File

@ -218,11 +218,8 @@ namespace Oqtane
installationManager.InstallPackages("Modules,Themes", false);
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseBlazorFrameworkFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();