Skip to content

Commit

Permalink
Merge pull request #4457 from sbwalker/dev
Browse files Browse the repository at this point in the history
change IsEffectiiveOrExpired to IsEffectiveAndNotExpired
  • Loading branch information
sbwalker authored Jul 23, 2024
2 parents 478a308 + 1cd4d6d commit 56eebb0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Oqtane.Client/Themes/Controls/Theme/LoginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected override void OnParametersSet()
logouturl = Utilities.TenantUrl(PageState.Alias, "/pages/logout/");

// verify anonymous users can access current page
if (UserSecurity.IsAuthorized(null, PermissionNames.View, PageState.Page.PermissionList) && Utilities.IsEffectiveOrExpired(PageState.Page.EffectiveDate, PageState.Page.ExpiryDate))
if (UserSecurity.IsAuthorized(null, PermissionNames.View, PageState.Page.PermissionList) && Utilities.IsEffectiveAndNotExpired(PageState.Page.EffectiveDate, PageState.Page.ExpiryDate))
{
returnurl = PageState.Route.PathAndQuery;
}
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/UI/SiteRouter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
}

// check if user is authorized to view page
if (page != null && UserSecurity.IsAuthorized(user, PermissionNames.View, page.PermissionList) && (Utilities.IsEffectiveOrExpired(page.EffectiveDate, page.ExpiryDate) || UserSecurity.IsAuthorized(user, PermissionNames.Edit, page.PermissionList)))
if (page != null && UserSecurity.IsAuthorized(user, PermissionNames.View, page.PermissionList) && (Utilities.IsEffectiveAndNotExpired(page.EffectiveDate, page.ExpiryDate) || UserSecurity.IsAuthorized(user, PermissionNames.Edit, page.PermissionList)))
{
// edit mode
if (user != null)
Expand Down
4 changes: 2 additions & 2 deletions Oqtane.Server/Infrastructure/Jobs/SearchIndexJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public override async Task<string> ExecuteJobAsync(IServiceProvider provider)
if (page.ModifiedOn >= lastIndexedOn && !ignoreEntities.Contains(EntityNames.Page))
{
changed = true;
removed = page.IsDeleted || !Utilities.IsEffectiveOrExpired(page.EffectiveDate, page.ExpiryDate);
removed = page.IsDeleted || !Utilities.IsEffectiveAndNotExpired(page.EffectiveDate, page.ExpiryDate);

var searchContent = new SearchContent
{
Expand Down Expand Up @@ -229,7 +229,7 @@ private void ValidateSearchContent(SearchContent searchContent, PageModule pageM
searchContent.AdditionalContent = string.Empty;
}

if (removed || pageModule.IsDeleted || !Utilities.IsEffectiveOrExpired(pageModule.EffectiveDate, pageModule.ExpiryDate))
if (removed || pageModule.IsDeleted || !Utilities.IsEffectiveAndNotExpired(pageModule.EffectiveDate, pageModule.ExpiryDate))
{
searchContent.IsDeleted = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Server/Managers/UserManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private string GetUserRoles(int userId, int siteId)
List<UserRole> userroles = _userRoles.GetUserRoles(userId, siteId).ToList();
foreach (UserRole userrole in userroles)
{
if (Utilities.IsEffectiveOrExpired(userrole.EffectiveDate, userrole.ExpiryDate))
if (Utilities.IsEffectiveAndNotExpired(userrole.EffectiveDate, userrole.ExpiryDate))
{
roles += userrole.Role.Name + ";";
if (userrole.Role.Name == RoleNames.Host && !userroles.Any(item => item.Role.Name == RoleNames.Admin))
Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Server/Security/UserPermissions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public User GetUser(ClaimsPrincipal principal)
var role = userRoles.FirstOrDefault(item => item.Role.Name == roleName);
if (role != null)
{
if (Utilities.IsEffectiveOrExpired(role.EffectiveDate,role.ExpiryDate))
if (Utilities.IsEffectiveAndNotExpired(role.EffectiveDate,role.ExpiryDate))
{
user.Roles += roleName + ";";
}
Expand Down
4 changes: 2 additions & 2 deletions Oqtane.Server/Services/SiteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task<Site> GetSiteAsync(int siteId)
var pages = new List<Page>();
foreach (Page page in site.Pages)
{
if (!page.IsDeleted && _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.View, page.PermissionList) && (Utilities.IsEffectiveOrExpired(page.EffectiveDate, page.ExpiryDate) || _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.Edit, page.PermissionList)))
if (!page.IsDeleted && _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.View, page.PermissionList) && (Utilities.IsEffectiveAndNotExpired(page.EffectiveDate, page.ExpiryDate) || _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.Edit, page.PermissionList)))
{
pages.Add(page);
}
Expand Down Expand Up @@ -256,7 +256,7 @@ public async Task<List<Module>> GetModulesAsync(int siteId, int pageId)
var modules = new List<Module>();
foreach (Module module in sitemodules.Where(item => (item.PageId == pageId || pageId == -1) && !item.IsDeleted && _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.View, item.PermissionList)))
{
if (Utilities.IsEffectiveOrExpired(module.EffectiveDate, module.ExpiryDate) || _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.Edit, module.PermissionList))
if (Utilities.IsEffectiveAndNotExpired(module.EffectiveDate, module.ExpiryDate) || _userPermissions.IsAuthorized(_accessor.HttpContext.User, PermissionNames.Edit, module.PermissionList))
{
modules.Add(module);
}
Expand Down
6 changes: 3 additions & 3 deletions Oqtane.Shared/Shared/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ public static (DateTime? date, string time) UtcAsLocalDateAndTime(DateTime? date

return (localDateTime?.Date, localTime);
}
public static bool IsEffectiveOrExpired(DateTime? effectiveDate, DateTime? expiryDate)
public static bool IsEffectiveAndNotExpired(DateTime? effectiveDate, DateTime? expiryDate)
{
DateTime currentUtcTime = DateTime.UtcNow;

Expand Down Expand Up @@ -626,10 +626,10 @@ public static string ContentUrl(Alias alias, int fileId, bool asAttachment)
return $"{alias?.BaseUrl}{aliasUrl}{Constants.ContentUrl}{fileId}{method}";
}

[Obsolete("IsPageModuleVisible(DateTime?, DateTime?) is deprecated. Use IsEffectiveOrExpired(DateTime?, DateTime?) instead.", false)]
[Obsolete("IsPageModuleVisible(DateTime?, DateTime?) is deprecated. Use IsEffectiveAndNotExpired(DateTime?, DateTime?) instead.", false)]
public static bool IsPageModuleVisible(DateTime? effectiveDate, DateTime? expiryDate)
{
return IsEffectiveOrExpired(effectiveDate, expiryDate);
return IsEffectiveAndNotExpired(effectiveDate, expiryDate);
}

}
Expand Down

0 comments on commit 56eebb0

Please sign in to comment.