diff --git a/LearningHub.Nhs.WebUI/Interfaces/IUserGroupService.cs b/LearningHub.Nhs.WebUI/Interfaces/IUserGroupService.cs
index a333e0c89..eadae3363 100644
--- a/LearningHub.Nhs.WebUI/Interfaces/IUserGroupService.cs
+++ b/LearningHub.Nhs.WebUI/Interfaces/IUserGroupService.cs
@@ -22,6 +22,12 @@ public interface IUserGroupService
/// The .
Task> GetRoleUserGroupDetailForUserAsync(int userId);
+ ///
+ /// The UserHasCatalogueContributionPermission.
+ ///
+ /// The .
+ Task UserHasCatalogueContributionPermission();
+
///
/// Check if user has given permission.
///
diff --git a/LearningHub.Nhs.WebUI/Services/NavigationPermissionService.cs b/LearningHub.Nhs.WebUI/Services/NavigationPermissionService.cs
index 95e74022e..e381b0403 100644
--- a/LearningHub.Nhs.WebUI/Services/NavigationPermissionService.cs
+++ b/LearningHub.Nhs.WebUI/Services/NavigationPermissionService.cs
@@ -11,14 +11,19 @@
public class NavigationPermissionService : INavigationPermissionService
{
private readonly IResourceService resourceService;
+ private readonly IUserGroupService userGroupService;
///
/// Initializes a new instance of the class.
///
/// Resource service.
- public NavigationPermissionService(IResourceService resourceService)
+ /// UserGroup service.
+ public NavigationPermissionService(
+ IResourceService resourceService,
+ IUserGroupService userGroupService)
{
this.resourceService = resourceService;
+ this.userGroupService = userGroupService;
}
///
@@ -52,7 +57,7 @@ public async Task GetNavigationModelAsync(IPrincipal user, bool
}
else if (user.IsInRole("BlueUser"))
{
- return this.AuthenticatedBlueUser(controllerName);
+ return await this.AuthenticatedBlueUser(controllerName);
}
else
{
@@ -114,11 +119,11 @@ private NavigationModel AuthenticatedAdministrator(string controllerName)
///
/// The controller name.
/// The .
- private NavigationModel AuthenticatedBlueUser(string controllerName)
+ private async Task AuthenticatedBlueUser(string controllerName)
{
return new NavigationModel()
{
- ShowMyContributions = true,
+ ShowMyContributions = await this.userGroupService.UserHasCatalogueContributionPermission(),
ShowMyLearning = true,
ShowMyBookmarks = true,
ShowSearch = controllerName != "search" && controllerName != string.Empty,
diff --git a/LearningHub.Nhs.WebUI/Services/UserGroupService.cs b/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
index 6790a3143..826aa07a0 100644
--- a/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
+++ b/LearningHub.Nhs.WebUI/Services/UserGroupService.cs
@@ -45,7 +45,7 @@ public UserGroupService(
///
public async Task> GetRoleUserGroupDetailAsync()
{
- var cacheKey = $"{this.contextAccessor.HttpContext.User.Identity.GetCurrentUserId()}:AllRolesWithPermissions";
+ var cacheKey = $"{this.contextAccessor.HttpContext.User.Identity.GetCurrentUserId()}:AllRolesWithPermissions";
return await this.cacheService.GetOrFetchAsync(cacheKey, () => this.FetchRoleUserGroupDetailAsync());
}
@@ -56,6 +56,18 @@ public async Task> GetRoleUserGroupDetailForUserAsy
return await this.cacheService.GetOrFetchAsync(cacheKey, () => this.FetchRoleUserGroupDetailForUserAsync(userId));
}
+ ///
+ public async Task UserHasCatalogueContributionPermission()
+ {
+ var userRoleGroups = await this.GetRoleUserGroupDetailAsync();
+ if (userRoleGroups != null && userRoleGroups.Any(r => r.RoleName == "Local Admin" || r.RoleName == "Editor"))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
///
public async Task UserHasPermissionAsync(string permissionCode)
{