diff --git a/Oqtane.Client/Modules/Admin/Pages/Add.razor b/Oqtane.Client/Modules/Admin/Pages/Add.razor index c14da7b03..4cce0b938 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Add.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Add.razor @@ -256,9 +256,8 @@ { _pageId = Int32.Parse(PageState.QueryString["id"]); _parent = await PageService.GetPageAsync(_pageId); - if (_parent != null && !UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin)) + if (_parent != null) { - // non-admins are authorized to create child pages of current page _parentid = _parent.PageId.ToString(); } } @@ -376,6 +375,15 @@ page.SiteId = PageState.Page.SiteId; page.Name = _name; + if (_parentid == "-1") + { + page.ParentId = null; + } + else + { + page.ParentId = Int32.Parse(_parentid); + } + // path can be a link to an external url if (!_path.Contains("://")) { @@ -400,7 +408,7 @@ } else { - Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == Int32.Parse(_parentid)); + Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == page.ParentId); if (parent.Path == string.Empty) { page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); @@ -417,15 +425,6 @@ page.Path = _path; } - if (_parentid == "-1") - { - page.ParentId = null; - } - else - { - page.ParentId = Int32.Parse(_parentid); - } - var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId); if (_pages.Any(item => item.Path == page.Path)) { diff --git a/Oqtane.Client/Modules/Admin/Pages/Edit.razor b/Oqtane.Client/Modules/Admin/Pages/Edit.razor index ff0ca08f9..02e2a2779 100644 --- a/Oqtane.Client/Modules/Admin/Pages/Edit.razor +++ b/Oqtane.Client/Modules/Admin/Pages/Edit.razor @@ -518,6 +518,15 @@ _page.Name = _name; + if (_parentid == "-1") + { + _page.ParentId = null; + } + else + { + _page.ParentId = Int32.Parse(_parentid); + } + // path can be a link to an external url if (!_path.Contains("://")) { @@ -542,7 +551,7 @@ } else { - Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == Int32.Parse(_parentid)); + Page parent = PageState.Pages.FirstOrDefault(item => item.PageId == _page.ParentId); if (parent.Path == string.Empty) { _page.Path = Utilities.GetFriendlyUrl(parent.Name) + "/" + Utilities.GetFriendlyUrl(_path); @@ -559,15 +568,6 @@ _page.Path = _path; } - if (_parentid == "-1") - { - _page.ParentId = null; - } - else - { - _page.ParentId = Int32.Parse(_parentid); - } - var _pages = await PageService.GetPagesAsync(PageState.Site.SiteId); if (_pages.Any(item => item.Path == _page.Path && item.PageId != _page.PageId)) {