install/upgrade refactoring to consolidate all use cases and implement IInstallable interface for modules, moved tenant creation to site management UI, fixed z-order issues in Blazor theme, enhanced JS Interop methods to support integrity and crossorigin

This commit is contained in:
Shaun Walker
2020-04-30 13:58:04 -04:00
parent 099fddf2b6
commit 34538dd945
44 changed files with 1051 additions and 912 deletions

View File

@ -17,47 +17,48 @@ namespace Oqtane.Repository
int aliasId = -1;
string aliasName = "";
// get alias identifier based on request context
if (accessor.HttpContext != null)
if (siteState != null && siteState.Alias != null)
{
// check if an alias is passed as a querystring parameter ( for cross tenant access )
if (accessor.HttpContext.Request.Query.ContainsKey("aliasid"))
{
aliasId = int.Parse(accessor.HttpContext.Request.Query["aliasid"]);
}
else // get the alias from the request url
{
aliasName = accessor.HttpContext.Request.Host.Value;
string path = accessor.HttpContext.Request.Path.Value;
string[] segments = path.Split(new[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length > 1 && segments[1] == "api" && segments[0] != "~")
{
aliasName += "/" + segments[0];
}
if (aliasName.EndsWith("/"))
{
aliasName = aliasName.Substring(0, aliasName.Length - 1);
}
}
}
else // background processes can pass in an alias using the SiteState service
{
aliasId = siteState?.Alias?.AliasId ?? -1;
}
// get the alias and tenant
IEnumerable<Alias> aliases = aliasRepository.GetAliases().ToList(); // cached
if (aliasId != -1)
{
_alias = aliases.FirstOrDefault(item => item.AliasId == aliasId);
// background processes can pass in an alias using the SiteState service
_alias = siteState.Alias;
}
else
{
_alias = aliases.FirstOrDefault(item => item.Name == aliasName
//if here is only one alias and other methods fail, take it (case of startup install)
|| aliases.Count() == 1);
{
// get alias identifier based on request context
if (accessor.HttpContext != null)
{
// check if an alias is passed as a querystring parameter ( for cross tenant access )
if (accessor.HttpContext.Request.Query.ContainsKey("aliasid"))
{
aliasId = int.Parse(accessor.HttpContext.Request.Query["aliasid"]);
}
else // get the alias from the request url
{
aliasName = accessor.HttpContext.Request.Host.Value;
string path = accessor.HttpContext.Request.Path.Value;
string[] segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
if (segments.Length > 1 && segments[1] == "api" && segments[0] != "~")
{
aliasName += "/" + segments[0];
}
if (aliasName.EndsWith("/"))
{
aliasName = aliasName.Substring(0, aliasName.Length - 1);
}
}
}
// get the alias
IEnumerable<Alias> aliases = aliasRepository.GetAliases().ToList(); // cached
if (aliasId != -1)
{
_alias = aliases.FirstOrDefault(item => item.AliasId == aliasId);
}
else
{
_alias = aliases.FirstOrDefault(item => item.Name == aliasName || aliases.Count() == 1);
}
}
if (_alias != null)