This commit is contained in:
zel
2025-02-24 09:32:37 +08:00
parent c1ce758117
commit c1a6c7e618

View File

@@ -30,7 +30,7 @@ namespace ZelWiki
#region Current Page. #region Current Page.
/// <summary> /// <summary>
/// Custom page title set by a call to @@Title("...") ///
/// </summary> /// </summary>
public string? PageTitle { get; set; } public string? PageTitle { get; set; }
public bool ShouldCreatePage { get; set; } public bool ShouldCreatePage { get; set; }
@@ -40,7 +40,7 @@ namespace ZelWiki
public ProcessingInstructionCollection PageInstructions { get; set; } = new(); public ProcessingInstructionCollection PageInstructions { get; set; } = new();
/// <summary> /// <summary>
/// The "page" here is more of a "mock page", we use the name for various stuff. ///
/// </summary> /// </summary>
public IPage Page { get; set; } = new Models.DataModels.Page() { Name = GlobalConfiguration.Name }; public IPage Page { get; set; } = new Models.DataModels.Page() { Name = GlobalConfiguration.Name };
@@ -97,11 +97,6 @@ namespace ZelWiki
UserTheme = ConfigurationRepository.GetAllThemes().SingleOrDefault(o => o.Name == Profile.Theme) ?? GlobalConfiguration.SystemTheme; UserTheme = ConfigurationRepository.GetAllThemes().SingleOrDefault(o => o.Name == Profile.Theme) ?? GlobalConfiguration.SystemTheme;
IsAuthenticated = true; IsAuthenticated = true;
} }
else
{
//User is signed in, but does not have a profile.
//This likely means that the user has authenticated externally, but has yet to complete the signup process.
}
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -117,12 +112,6 @@ namespace ZelWiki
} }
} }
/// <summary>
/// Sets the current context pageId and optionally the revision.
/// </summary>
/// <param name="pageId"></param>
/// <param name="revision"></param>
/// <exception cref="Exception"></exception>
public void SetPageId(int? pageId, int? revision = null) public void SetPageId(int? pageId, int? revision = null)
{ {
Page = new Models.DataModels.Page(); Page = new Models.DataModels.Page();
@@ -184,12 +173,12 @@ namespace ZelWiki
} }
/// <summary> /// <summary>
/// Is the current user (or anonymous) allowed to view? ///
/// </summary> /// </summary>
public bool CanView => true; public bool CanView => true;
/// <summary> /// <summary>
/// Is the current user allowed to edit? ///
/// </summary> /// </summary>
public bool CanEdit public bool CanEdit
{ {
@@ -209,25 +198,25 @@ namespace ZelWiki
} }
/// <summary> /// <summary>
/// Is the current user allowed to perform administrative functions? ///
/// </summary> /// </summary>
public bool CanAdmin => public bool CanAdmin =>
IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator]); IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator]);
/// <summary> /// <summary>
/// Is the current user allowed to moderate content (such as delete comments, and view moderation tools)? ///
/// </summary> /// </summary>
public bool CanModerate => public bool CanModerate =>
IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator, Constants.Roles.Moderator]); IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator, Constants.Roles.Moderator]);
/// <summary> /// <summary>
/// Is the current user allowed to create pages? ///
/// </summary> /// </summary>
public bool CanCreate => public bool CanCreate =>
IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator, Constants.Roles.Contributor, Constants.Roles.Moderator]); IsAuthenticated && IsMemberOf(Role, [Constants.Roles.Administrator, Constants.Roles.Contributor, Constants.Roles.Moderator]);
/// <summary> /// <summary>
/// Is the current user allowed to delete unprotected pages? ///
/// </summary> /// </summary>
public bool CanDelete public bool CanDelete
{ {