Merge pull request #229 from sbwalker/master

further changes for site creation
This commit is contained in:
Shaun Walker 2020-02-26 01:40:31 -05:00 committed by GitHub
commit f908c104b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 9 deletions

View File

@ -5,6 +5,7 @@ using System.Linq;
using Microsoft.AspNetCore.Components;
using System.Collections.Generic;
using Oqtane.Shared;
using System.Net;
namespace Oqtane.Services
{
@ -45,7 +46,7 @@ namespace Oqtane.Services
}
else
{
return await http.PostJsonAsync<Site>(CreateApiUrl(Alias, NavigationManager.Uri, "Site"), Site);
return await http.PostJsonAsync<Site>(apiurl + "?alias=" + WebUtility.UrlEncode(Alias.Name), Site);
}
}

View File

@ -6,6 +6,7 @@ using System.Net.Http;
using Microsoft.AspNetCore.Components;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Net;
namespace Oqtane.Services
{
@ -53,7 +54,7 @@ namespace Oqtane.Services
{
try
{
return await http.PostJsonAsync<User>(CreateApiUrl(Alias, NavigationManager.Uri, "User"), User);
return await http.PostJsonAsync<User>(apiurl + "?alias=" + WebUtility.UrlEncode(Alias.Name), User);
}
catch
{

View File

@ -26,16 +26,24 @@ namespace Oqtane.Repository
// get alias based on request context
if (accessor.HttpContext != null)
{
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] != "~")
// check if an alias is passed as a querystring parameter
if (accessor.HttpContext.Request.Query.ContainsKey("alias"))
{
aliasname += "/" + segments[0];
aliasname = accessor.HttpContext.Request.Query["alias"];
}
if (aliasname.EndsWith("/"))
else // get the alias from the request url
{
aliasname = aliasname.Substring(0, aliasname.Length - 1);
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