optimizations and fixes
This commit is contained in:
@ -117,7 +117,7 @@
|
||||
{
|
||||
await logger.LogInformation("Login Successful For Username {Username}", Username);
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl(ReturnUrl));
|
||||
NavigationManager.NavigateTo(NavigateUrl(ReturnUrl, "reload"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,7 +85,7 @@
|
||||
string name = "";
|
||||
string type = "LocalDB";
|
||||
string server = "(LocalDb)\\MSSQLLocalDB";
|
||||
string database = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||
string database = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
string username = "";
|
||||
string password = "";
|
||||
string schema = "";
|
||||
|
@ -81,7 +81,7 @@
|
||||
notification.Subject = subject;
|
||||
notification.Body = body;
|
||||
notification.ParentId = null;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
|
||||
|
@ -140,7 +140,7 @@
|
||||
notification.Subject = subject;
|
||||
notification.Body = body;
|
||||
notification.ParentId = notificationid;
|
||||
notification.CreatedOn = DateTime.Now;
|
||||
notification.CreatedOn = DateTime.UtcNow;
|
||||
notification.IsDelivered = false;
|
||||
notification.DeliveredOn = null;
|
||||
|
||||
|
@ -37,6 +37,6 @@ else
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
WeatherForecastService forecastservice = new WeatherForecastService();
|
||||
forecasts = await forecastservice.GetForecastAsync(DateTime.Now);
|
||||
forecasts = await forecastservice.GetForecastAsync(DateTime.UtcNow);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace Oqtane.Services
|
||||
Task<List<Page>> GetPagesAsync(int SiteId);
|
||||
Task<Page> GetPageAsync(int PageId);
|
||||
Task<Page> GetPageAsync(int PageId, int UserId);
|
||||
Task<Page> GetPageAsync(string Path, int SiteId);
|
||||
Task<Page> AddPageAsync(Page Page);
|
||||
Task<Page> AddPageAsync(int PageId, int UserId);
|
||||
Task<Page> UpdatePageAsync(Page Page);
|
||||
|
@ -59,13 +59,13 @@ namespace Oqtane.Services
|
||||
|
||||
public async Task LoadModuleDefinitionsAsync(int SiteId)
|
||||
{
|
||||
// get list of modules from the server
|
||||
List<ModuleDefinition> moduledefinitions = await GetModuleDefinitionsAsync(SiteId);
|
||||
|
||||
// download assemblies to browser when running client-side Blazor
|
||||
var authstateprovider = (IdentityAuthenticationStateProvider)_serviceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
|
||||
if (authstateprovider != null)
|
||||
{
|
||||
// get list of modules from the server
|
||||
List<ModuleDefinition> moduledefinitions = await GetModuleDefinitionsAsync(SiteId);
|
||||
|
||||
// get list of loaded assemblies on the client ( in the client-side hosting module the browser client has its own app domain )
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Shared;
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
@ -44,6 +45,18 @@ namespace Oqtane.Services
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/" + PageId.ToString() + "?userid=" + UserId.ToString());
|
||||
}
|
||||
|
||||
public async Task<Page> GetPageAsync(string Path, int SiteId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _http.GetJsonAsync<Page>(apiurl + "/path/" + SiteId.ToString() + "?path=" + WebUtility.UrlEncode(Path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Page> AddPageAsync(Page Page)
|
||||
{
|
||||
return await _http.PostJsonAsync<Page>(apiurl, Page);
|
||||
|
@ -76,7 +76,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<label for="Module" class="control-label">Module: </label>
|
||||
<label for="Module" class="control-label">Module Management: </label>
|
||||
<select class="form-control" @bind="@_moduleType">
|
||||
<option value="new">Add New Module</option>
|
||||
<option value="existing">Add Existing Module</option>
|
||||
|
@ -46,7 +46,7 @@
|
||||
{
|
||||
// client-side Blazor
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path));
|
||||
NavigationManager.NavigateTo(NavigateUrl(PageState.Page.Path, "reload"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<hr class="app-rule" />
|
||||
<h2 class="text-center">Database Configuration</h2>
|
||||
<div class="row">
|
||||
<div class="mx-auto text-center">
|
||||
<table class="form-group" cellpadding="4" cellspacing="4">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col text-center">
|
||||
<h2>Database Configuration</h2><br />
|
||||
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
@ -73,12 +73,9 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="app-rule" />
|
||||
<h2 class="text-center">Application Administrator</h2>
|
||||
<div class="row">
|
||||
<div class="mx-auto text-center">
|
||||
<table class="form-group" cellpadding="4" cellspacing="4">
|
||||
<div class="col text-center">
|
||||
<h2>Application Administrator</h2><br />
|
||||
<table class="form-group" cellpadding="4" cellspacing="4" style="margin: auto;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
@ -116,6 +113,7 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<hr class="app-rule" />
|
||||
<div class="row">
|
||||
<div class="mx-auto text-center">
|
||||
<button type="button" class="btn btn-success" @onclick="Install">Install Now</button><br /><br />
|
||||
@ -128,7 +126,7 @@
|
||||
@code {
|
||||
private string DatabaseType = "LocalDB";
|
||||
private string ServerName = "(LocalDb)\\MSSQLLocalDB";
|
||||
private string DatabaseName = "Oqtane-" + DateTime.Now.ToString("yyyyMMddHHmm");
|
||||
private string DatabaseName = "Oqtane-" + DateTime.UtcNow.ToString("yyyyMMddHHmm");
|
||||
private string Username = "";
|
||||
private string Password = "";
|
||||
private string HostUsername = Constants.HostUser;
|
||||
|
@ -10,6 +10,7 @@
|
||||
@inject IUserService UserService
|
||||
@inject IModuleService ModuleService
|
||||
@inject IModuleDefinitionService ModuleDefinitionService
|
||||
@inject ILogService LogService
|
||||
@implements IHandleAfterRender
|
||||
|
||||
@DynamicComponent
|
||||
@ -75,7 +76,6 @@
|
||||
int moduleid = -1;
|
||||
string action = "";
|
||||
bool editmode = false;
|
||||
int userid = -1;
|
||||
Reload reload = Reload.None;
|
||||
DateTime lastsyncdate = DateTime.UtcNow;
|
||||
|
||||
@ -94,23 +94,39 @@
|
||||
path = path.Substring(0, path.IndexOf("?"));
|
||||
}
|
||||
|
||||
// the reload parameter is used during user login/logout
|
||||
if (querystring.ContainsKey("reload"))
|
||||
{
|
||||
reload = Reload.Site;
|
||||
}
|
||||
|
||||
if (PageState != null)
|
||||
{
|
||||
editmode = PageState.EditMode;
|
||||
lastsyncdate = PageState.LastSyncDate;
|
||||
if (PageState.User != null)
|
||||
{
|
||||
userid = PageState.User.UserId;
|
||||
}
|
||||
}
|
||||
|
||||
alias = await AliasService.GetAliasAsync(_absoluteUri, lastsyncdate);
|
||||
SiteState.Alias = alias; // set state for services
|
||||
lastsyncdate = alias.SyncDate;
|
||||
|
||||
if (PageState == null || alias.SiteId != PageState.Alias.SiteId)
|
||||
// process any sync events for site or page
|
||||
if (reload != Reload.Site && alias.SyncEvents.Any())
|
||||
{
|
||||
if (PageState != null && alias.SyncEvents.Exists(item => item.EntityName == "Page" && item.EntityId == PageState.Page.PageId))
|
||||
{
|
||||
reload = Reload.Page;
|
||||
}
|
||||
if (alias.SyncEvents.Exists(item => item.EntityName == "Site" && item.EntityId == alias.SiteId))
|
||||
{
|
||||
reload = Reload.Site;
|
||||
}
|
||||
}
|
||||
|
||||
if (reload == Reload.Site || PageState == null || alias.SiteId != PageState.Alias.SiteId)
|
||||
{
|
||||
site = await SiteService.GetSiteAsync(alias.SiteId, alias);
|
||||
reload = Reload.Site;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -118,29 +134,24 @@
|
||||
}
|
||||
if (site != null)
|
||||
{
|
||||
// get user
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
if (authState.User.Identity.IsAuthenticated)
|
||||
if (PageState == null || reload == Reload.Site)
|
||||
{
|
||||
user = await UserService.GetUserAsync(authState.User.Identity.Name, site.SiteId);
|
||||
if (user != null)
|
||||
// get user
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
if (authState.User.Identity.IsAuthenticated)
|
||||
{
|
||||
userid = user.UserId;
|
||||
user = await UserService.GetUserAsync(authState.User.Identity.Name, site.SiteId);
|
||||
}
|
||||
}
|
||||
|
||||
// process sync events
|
||||
if (alias.SyncEvents.Any())
|
||||
else
|
||||
{
|
||||
if (PageState != null && alias.SyncEvents.Exists(item => item.EntityName == "Page" && item.EntityId == PageState.Page.PageId))
|
||||
{
|
||||
reload = Reload.Page;
|
||||
}
|
||||
if (alias.SyncEvents.Exists(item => item.EntityName == "Site" && item.EntityId == alias.SiteId))
|
||||
{
|
||||
reload = Reload.Site;
|
||||
}
|
||||
if (alias.SyncEvents.Exists(item => item.EntityName == "User" && item.EntityId == userid))
|
||||
user = PageState.User;
|
||||
}
|
||||
|
||||
// process any sync events for user
|
||||
if (reload != Reload.Site && user != null && alias.SyncEvents.Any())
|
||||
{
|
||||
if (alias.SyncEvents.Exists(item => item.EntityName == "User" && item.EntityId == user.UserId))
|
||||
{
|
||||
reload = Reload.Site;
|
||||
}
|
||||
@ -148,7 +159,7 @@
|
||||
|
||||
if (PageState == null || reload >= Reload.Site)
|
||||
{
|
||||
await ModuleDefinitionService.LoadModuleDefinitionsAsync(site.SiteId);
|
||||
await ModuleDefinitionService.LoadModuleDefinitionsAsync(site.SiteId);
|
||||
pages = await PageService.GetPagesAsync(site.SiteId);
|
||||
}
|
||||
else
|
||||
@ -206,7 +217,7 @@
|
||||
{
|
||||
page = pages.Where(item => item.Path == path).FirstOrDefault();
|
||||
reload = Reload.Page;
|
||||
if (page!=null)
|
||||
if (page != null)
|
||||
{
|
||||
editmode = page.EditMode;
|
||||
}
|
||||
@ -255,21 +266,23 @@
|
||||
|
||||
OnStateChange?.Invoke(pagestate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// user is not authorized to view page
|
||||
if (path != "")
|
||||
{
|
||||
NavigationManager.NavigateTo("");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// page does not exist
|
||||
if (path != "")
|
||||
if (user == null)
|
||||
{
|
||||
NavigationManager.NavigateTo("");
|
||||
await LogService.Log(null, null, null, GetType().AssemblyQualifiedName, Utilities.GetTypeNameLastSegment(GetType().AssemblyQualifiedName, 1), LogFunction.Security, LogLevel.Error, null, "Page Does Not Exist Or User Is Not Authorized To View Page {Path}", path);
|
||||
// redirect to login page
|
||||
NavigationManager.NavigateTo(Utilities.NavigateUrl(alias.Path, "login", "returnurl=" + path));
|
||||
}
|
||||
else
|
||||
{
|
||||
await LogService.Log(null, null, user.UserId, GetType().AssemblyQualifiedName, Utilities.GetTypeNameLastSegment(GetType().AssemblyQualifiedName, 1), LogFunction.Security, LogLevel.Error, null, "Page Does Not Exist Or User Is Not Authorized To View Page {Path}", path);
|
||||
if (path != "")
|
||||
{
|
||||
// redirect to home page
|
||||
NavigationManager.NavigateTo(Utilities.NavigateUrl(alias.Path, "", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user