added security attribute to TenantController Get methods and resolved TenantId on server during Installation
This commit is contained in:
parent
91c7528856
commit
414935dc58
|
@ -2,7 +2,6 @@
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
@inject ISiteService SiteService
|
@inject ISiteService SiteService
|
||||||
@inject ITenantService TenantService
|
|
||||||
@inject IUserService UserService
|
@inject IUserService UserService
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -172,9 +171,8 @@
|
||||||
GenericResponse response = await InstallationService.Install(connectionstring);
|
GenericResponse response = await InstallationService.Install(connectionstring);
|
||||||
if (response.Success)
|
if (response.Success)
|
||||||
{
|
{
|
||||||
List<Tenant> tenants = await TenantService.GetTenantsAsync();
|
|
||||||
Site site = new Site();
|
Site site = new Site();
|
||||||
site.TenantId = tenants.FirstOrDefault().TenantId;
|
site.TenantId = -1; // will be populated on server
|
||||||
site.Name = "Default Site";
|
site.Name = "Default Site";
|
||||||
site.Logo = "oqtane.png";
|
site.Logo = "oqtane.png";
|
||||||
site.DefaultThemeType = Constants.DefaultTheme;
|
site.DefaultThemeType = Constants.DefaultTheme;
|
||||||
|
|
|
@ -50,7 +50,10 @@ namespace Oqtane.Controllers
|
||||||
bool authorized;
|
bool authorized;
|
||||||
if (!Sites.GetSites().Any())
|
if (!Sites.GetSites().Any())
|
||||||
{
|
{
|
||||||
authorized = true; // provision initial site during installation
|
// provision initial site during installation
|
||||||
|
authorized = true;
|
||||||
|
Tenant tenant = Tenants.GetTenant();
|
||||||
|
Site.TenantId = tenant.TenantId;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET: api/<controller>
|
// GET: api/<controller>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
public IEnumerable<Tenant> Get()
|
public IEnumerable<Tenant> Get()
|
||||||
{
|
{
|
||||||
return Tenants.GetTenants();
|
return Tenants.GetTenants();
|
||||||
|
@ -29,6 +30,7 @@ namespace Oqtane.Controllers
|
||||||
|
|
||||||
// GET api/<controller>/5
|
// GET api/<controller>/5
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
|
[Authorize(Roles = Constants.HostRole)]
|
||||||
public Tenant Get(int id)
|
public Tenant Get(int id)
|
||||||
{
|
{
|
||||||
return Tenants.GetTenant(id);
|
return Tenants.GetTenant(id);
|
||||||
|
|
|
@ -95,27 +95,29 @@ namespace Oqtane.Infrastructure
|
||||||
names.Add(message.Substring(index + 1, message.IndexOf("}", index) - index - 1));
|
names.Add(message.Substring(index + 1, message.IndexOf("}", index) - index - 1));
|
||||||
if (values.Length > (names.Count - 1))
|
if (values.Length > (names.Count - 1))
|
||||||
{
|
{
|
||||||
message = message.Replace("{" + names[names.Count - 1] + "}", values[names.Count - 1]?.ToString() ?? "null");
|
if (values[names.Count - 1] == null)
|
||||||
|
{
|
||||||
|
message = message.Replace("{" + names[names.Count - 1] + "}", "null");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = message.Replace("{" + names[names.Count - 1] + "}", values[names.Count - 1].ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
index = message.IndexOf("{", index + 1);
|
index = message.IndexOf("{", index + 1);
|
||||||
}
|
}
|
||||||
// rebuild properties into dictionary
|
// rebuild properties into dictionary
|
||||||
Dictionary<string, string> propertydictionary = new Dictionary<string, string>();
|
Dictionary<string, object> propertydictionary = new Dictionary<string, object>();
|
||||||
for (int i = 0; i < values.Length; i++)
|
for (int i = 0; i < values.Length; i++)
|
||||||
{
|
{
|
||||||
string value = "";
|
|
||||||
if (values[i] != null)
|
|
||||||
{
|
|
||||||
value = values[i].ToString();
|
|
||||||
}
|
|
||||||
if (i < names.Count)
|
if (i < names.Count)
|
||||||
{
|
{
|
||||||
propertydictionary.Add(names[i], value);
|
propertydictionary.Add(names[i], values[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
propertydictionary.Add("Property" + i.ToString(), value);
|
propertydictionary.Add("Property" + i.ToString(), values[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
properties = JsonSerializer.Serialize(propertydictionary);
|
properties = JsonSerializer.Serialize(propertydictionary);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user