From 12fde4911c3803a2ce4facccbf23d4dfaeeca8cc Mon Sep 17 00:00:00 2001 From: binon Date: Thu, 18 Jan 2024 10:41:14 +0000 Subject: [PATCH 1/2] WebAPI - hot fix changes --- .../Scripts/ExternalSystemData.sql | 38 +++++++++++++++++++ .../GetNodeContentsForCatalogueBrowse.sql | 2 +- ...ntsForCatalogueBrowse_withEmptyFolders.sql | 2 +- .../HierarchyService.cs | 9 ++++- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/ExternalSystemData.sql b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/ExternalSystemData.sql index 8ed6229df..5560158ab 100644 --- a/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/ExternalSystemData.sql +++ b/WebAPI/LearningHub.Nhs.Database/Scripts/Post-Deploy/Scripts/ExternalSystemData.sql @@ -17,3 +17,41 @@ INSERT INTO [external].[ExternalSystemDeepLink] ,57541 ,SYSDATETIMEOFFSET()) END + +IF NOT EXISTS (SELECT 1 FROM [external].[ExternalSystem] WHERE [Code] = 'DigitalLearningSolutionsSso') +BEGIN +INSERT INTO [external].[ExternalSystem] + ([Name] + ,[Code] + ,[CallbackUrl] + ,[SecretKey] + ,[TermsAndConditions] + ,[DefaultUserGroupId] + ,[DefaultStaffGroupId] + ,[DefaultJobRoleId] + ,[DefaultGradingId] + ,[DefaultSpecialityId] + ,[DefaultLocationId] + ,[Deleted] + ,[CreateUserId] + ,[CreateDate] + ,[AmendUserId] + ,[AmendDate]) + VALUES + ('Digital Learning Solutions' + ,'DigitalLearningSolutionsSso' + ,'https://www.dls.nhs.uk/v2/linkaccount/accountlinked' + ,'74A90C2B-5BC5-4877-8607-43AD08DEA983' + ,'By clicking the button below, you agree to the Learning Hub and Digital Learning Solutions creating a link between your accounts on their systems so that you can log in to the Learning Hub seamlessly from the Digital Learning Solutions site via Single Sign On. Do you agree to the Learning Hub and Digital Learning Solutions linking your accounts?' + ,'1070' + ,null + ,null + ,null + ,227 + ,1 + ,0 + ,57541 + ,SYSDATETIMEOFFSET() + ,57541 + ,SYSDATETIMEOFFSET()) +END diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse.sql index 0bd9f3f52..6c2c4fb8d 100644 --- a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse.sql +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse.sql @@ -122,6 +122,6 @@ BEGIN AND rv.Deleted = 0 ) AS t1 - ORDER BY DisplayOrder ASC + ORDER BY NodeTypeId DESC,DisplayOrder ASC END GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse_withEmptyFolders.sql b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse_withEmptyFolders.sql index 9dfa34fe7..1e0000213 100644 --- a/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse_withEmptyFolders.sql +++ b/WebAPI/LearningHub.Nhs.Database/Stored Procedures/Hierarchy/GetNodeContentsForCatalogueBrowse_withEmptyFolders.sql @@ -117,6 +117,6 @@ BEGIN AND rv.Deleted = 0 ) AS t1 - ORDER BY DisplayOrder ASC + ORDER BY NodeTypeId DESC,DisplayOrder ASC END GO \ No newline at end of file diff --git a/WebAPI/LearningHub.Nhs.Services/HierarchyService.cs b/WebAPI/LearningHub.Nhs.Services/HierarchyService.cs index 9b9d97e7d..0f55404f7 100644 --- a/WebAPI/LearningHub.Nhs.Services/HierarchyService.cs +++ b/WebAPI/LearningHub.Nhs.Services/HierarchyService.cs @@ -269,6 +269,10 @@ public async Task> GetNodeContentsForCatalogueB string cacheKey = $"{CacheKeys.PublishedNodeContents}:{nodeId}"; var nodeContents = await this.cachingService.GetAsync>(cacheKey); + if (includeEmptyFolder) + { + nodeContents.ResponseEnum = CacheReadResponseEnum.NotFound; + } if (nodeContents.ResponseEnum == CacheReadResponseEnum.Found) { @@ -285,7 +289,10 @@ public async Task> GetNodeContentsForCatalogueB throw new Exception($"Corrupt data. Duplicate Nodes returned in NodeContent for NodeId={nodeId}"); } - await this.cachingService.SetAsync(cacheKey, retVal); + if (!includeEmptyFolder) + { + await this.cachingService.SetAsync(cacheKey, retVal); + } } var list = retVal.Where(ncm => ncm.ResourceVersionId.HasValue); From abddd2ccdb2cab8ceef394346a91503ce636f77f Mon Sep 17 00:00:00 2001 From: binon Date: Thu, 18 Jan 2024 10:50:46 +0000 Subject: [PATCH 2/2] RC hot fixes WebUI --- .gitguardian.yaml | 5 + .../Controllers/Api/UserController.cs | 12 ++ .../Controllers/ResourceController.cs | 2 +- .../Scripts/vuesrc/data/user.ts | 15 +- .../vuesrc/resource/ResourceContent.vue | 23 +- .../resource/blocks/ImageCarouselViewer.vue | 3 +- .../Services/SearchService.cs | 9 +- .../Views/Catalogue/Catalogues.cshtml | 196 +++++++++--------- .../Views/Home/_CatalogueCard.cshtml | 2 +- .../Views/Home/_ResourceCard.cshtml | 130 ++++++------ .../Search/_CatalogueSearchResult.cshtml | 170 +++++++-------- .../Views/Search/_ResourceSearchResult.cshtml | 148 ++++++------- 12 files changed, 373 insertions(+), 342 deletions(-) create mode 100644 .gitguardian.yaml diff --git a/.gitguardian.yaml b/.gitguardian.yaml new file mode 100644 index 000000000..0685713d8 --- /dev/null +++ b/.gitguardian.yaml @@ -0,0 +1,5 @@ +secret: + ignored-matches: + - match: 26841b2b92a38ec6d2dd87ccc2d4f6d3613486c21f4cf5cb4d98b4527dfc0061 + name: Generic High Entropy Secret - LearningHub.Nhs.WebUI/Program.cs +version: 2 diff --git a/LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs b/LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs index e2b9c09b5..7e5d42864 100644 --- a/LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs @@ -90,6 +90,18 @@ public async Task GetUserAccessType() return this.Ok(isGeneralUser); } + /// + /// to get user role. + /// + /// The . + [HttpGet] + [Route("CheckUserRole")] + public async Task CheckUserRole() + { + var isSystemAdmin = this.User.IsInRole("Administrator"); + return this.Ok(isSystemAdmin); + } + /// /// The GetCurrentUserPersonalDetails. /// diff --git a/LearningHub.Nhs.WebUI/Controllers/ResourceController.cs b/LearningHub.Nhs.WebUI/Controllers/ResourceController.cs index 97df3861f..b040c2cf8 100644 --- a/LearningHub.Nhs.WebUI/Controllers/ResourceController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/ResourceController.cs @@ -136,7 +136,7 @@ public async Task Index(int resourceReferenceId, bool? acceptSens var userGroups = await this.userGroupService.GetRoleUserGroupDetailForUserAsync(this.CurrentUserId); hasCatalogueAccess = userGroups.Any(x => x.CatalogueNodeId == resource.Catalogue.NodeId && - (x.RoleEnum == RoleEnum.LocalAdmin || x.RoleEnum == RoleEnum.Editor || x.RoleEnum == RoleEnum.Reader)); + (x.RoleEnum == RoleEnum.LocalAdmin || x.RoleEnum == RoleEnum.Editor || x.RoleEnum == RoleEnum.Reader)) || this.User.IsInRole("Administrator"); } else if (!resource.Catalogue.RestrictedAccess) { diff --git a/LearningHub.Nhs.WebUI/Scripts/vuesrc/data/user.ts b/LearningHub.Nhs.WebUI/Scripts/vuesrc/data/user.ts index 757b948ba..472ca9bac 100644 --- a/LearningHub.Nhs.WebUI/Scripts/vuesrc/data/user.ts +++ b/LearningHub.Nhs.WebUI/Scripts/vuesrc/data/user.ts @@ -54,6 +54,18 @@ const isGeneralUser = async function (): Promise { }); }; +const IsSystemAdmin = async function (): Promise { + var IsSystemAdmin = `/api/User/CheckUserRole`; + return await AxiosWrapper.axios.get(IsSystemAdmin) + .then(response => { + return response.data; + }) + .catch(e => { + console.log('IsSystemAdmin:' + e); + throw e; + }); +}; + const getCurrentUserBasicDetails = async function (): Promise { return await AxiosWrapper.axios.get('/api/User/GetCurrentUserBasicDetails') .then(response => { @@ -160,5 +172,6 @@ export const userData = { updateSecurityQuestionAnswers, keepUserSessionAlive, getkeepUserSessionAliveInterval, - isGeneralUser + isGeneralUser, + IsSystemAdmin } diff --git a/LearningHub.Nhs.WebUI/Scripts/vuesrc/resource/ResourceContent.vue b/LearningHub.Nhs.WebUI/Scripts/vuesrc/resource/ResourceContent.vue index efc9dad7c..fd68981da 100644 --- a/LearningHub.Nhs.WebUI/Scripts/vuesrc/resource/ResourceContent.vue +++ b/LearningHub.Nhs.WebUI/Scripts/vuesrc/resource/ResourceContent.vue @@ -8,7 +8,7 @@
- +