commit
b0c1c6e880
@ -112,21 +112,11 @@
|
|||||||
{
|
{
|
||||||
PageState.EditMode = !editMode;
|
PageState.EditMode = !editMode;
|
||||||
|
|
||||||
if(PageState.User != null) //keep edit mode for authenticated users.
|
if (PageState.User != null)
|
||||||
{
|
{
|
||||||
if(PageState.EditMode)
|
// preserve edit mode for authenticated users
|
||||||
{
|
var userSettings = new Dictionary<string, string> { { "CP-editmode", (PageState.EditMode) ? PageState.Page.PageId.ToString() : "-1" } };
|
||||||
var userSettings = new Dictionary<string, string>
|
await SettingService.UpdateUserSettingsAsync(userSettings, PageState.User.UserId);
|
||||||
{
|
|
||||||
{ UserSetting.LastViewPageId, PageState.Page.PageId.ToString() }
|
|
||||||
};
|
|
||||||
|
|
||||||
await SettingService.UpdateUserSettingsAsync(userSettings, PageState.User.UserId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await SettingService.DeleteSettingAsync(EntityNames.User, PageState.User.UserId, UserSetting.LastViewPageId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// preserve other querystring parameters
|
// preserve other querystring parameters
|
||||||
|
@ -148,18 +148,11 @@
|
|||||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||||
if (authState.User.Identity.IsAuthenticated && authState.User.Claims.Any(item => item.Type == "sitekey" && item.Value == SiteState.Alias.SiteKey))
|
if (authState.User.Identity.IsAuthenticated && authState.User.Claims.Any(item => item.Type == "sitekey" && item.Value == SiteState.Alias.SiteKey))
|
||||||
{
|
{
|
||||||
if (PageState == null || PageState.Refresh || refresh || PageState.Alias.SiteId != SiteState.Alias.SiteId)
|
// get user
|
||||||
|
user = await UserService.GetUserAsync(authState.User.Identity.Name, SiteState.Alias.SiteId);
|
||||||
|
if (user != null)
|
||||||
{
|
{
|
||||||
// get user
|
user.IsAuthenticated = authState.User.Identity.IsAuthenticated;
|
||||||
user = await UserService.GetUserAsync(authState.User.Identity.Name, SiteState.Alias.SiteId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
user.IsAuthenticated = authState.User.Identity.IsAuthenticated;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user = PageState.User;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,40 +163,6 @@
|
|||||||
visitorId = PageState.VisitorId;
|
visitorId = PageState.VisitorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool? pageChanged = null;
|
|
||||||
if(user != null && PageState?.Page != null)
|
|
||||||
{
|
|
||||||
var userSettings = await SettingService.GetUserSettingsAsync(user.UserId);
|
|
||||||
if(userSettings.ContainsKey(UserSetting.LastViewPageId))
|
|
||||||
{
|
|
||||||
int.TryParse(userSettings.GetValueOrDefault(UserSetting.LastViewPageId), out int lastViewPageId);
|
|
||||||
pageChanged = lastViewPageId != PageState.Page.PageId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PageState?.Page.Path != route.PagePath || pageChanged.GetValueOrDefault(false))
|
|
||||||
{
|
|
||||||
editmode = false; // reset edit mode when navigating to different page
|
|
||||||
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
await SettingService.DeleteSettingAsync(EntityNames.User, user.UserId, UserSetting.LastViewPageId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (querystring.ContainsKey("edit") && querystring["edit"] == "true")
|
|
||||||
{
|
|
||||||
editmode = true; // querystring can set edit mode
|
|
||||||
}
|
|
||||||
|
|
||||||
//check edit mode for authenticated users.
|
|
||||||
if (!editmode && user != null)
|
|
||||||
{
|
|
||||||
editmode = pageChanged.HasValue && !pageChanged.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// process any sync events
|
// process any sync events
|
||||||
var sync = await SyncService.GetSyncEventsAsync(lastsyncdate);
|
var sync = await SyncService.GetSyncEventsAsync(lastsyncdate);
|
||||||
lastsyncdate = sync.SyncDate;
|
lastsyncdate = sync.SyncDate;
|
||||||
@ -298,6 +257,24 @@
|
|||||||
// check if user is authorized to view page
|
// check if user is authorized to view page
|
||||||
if (UserSecurity.IsAuthorized(user, PermissionNames.View, page.PermissionList) && (Utilities.IsPageModuleVisible(page.EffectiveDate, page.ExpiryDate) || UserSecurity.IsAuthorized(user, PermissionNames.Edit, page.PermissionList)))
|
if (UserSecurity.IsAuthorized(user, PermissionNames.View, page.PermissionList) && (Utilities.IsPageModuleVisible(page.EffectiveDate, page.ExpiryDate) || UserSecurity.IsAuthorized(user, PermissionNames.Edit, page.PermissionList)))
|
||||||
{
|
{
|
||||||
|
// edit mode
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
if (querystring.ContainsKey("editmode") && querystring["edit"] == "true")
|
||||||
|
{
|
||||||
|
editmode = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
editmode = (page.PageId == ((user.Settings.ContainsKey("CP-editmode")) ? int.Parse(user.Settings["CP-editmode"]) : -1));
|
||||||
|
if (!editmode)
|
||||||
|
{
|
||||||
|
var userSettings = new Dictionary<string, string> { { "CP-editmode", "-1" } };
|
||||||
|
await SettingService.UpdateUserSettingsAsync(userSettings, user.UserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// load additional metadata for current page
|
// load additional metadata for current page
|
||||||
page = ProcessPage(page, site, user, SiteState.Alias);
|
page = ProcessPage(page, site, user, SiteState.Alias);
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Oqtane.Models
|
|
||||||
{
|
|
||||||
public class UserSetting
|
|
||||||
{
|
|
||||||
public const string LastViewPageId = "Page:LastViewed";
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user