diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/INavigationPermissionService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/INavigationPermissionService.cs index 7095bc71..6319ab1f 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/INavigationPermissionService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/INavigationPermissionService.cs @@ -15,8 +15,9 @@ public interface INavigationPermissionService /// User. /// Login wizard complete. /// Controller name. + /// The current user id. /// A representing the result of the asynchronous operation. - Task GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName); + Task GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName, int currentUserId); /// /// The NotAuthenticated. diff --git a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs index bd4cb5e1..a8c6ceb7 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs @@ -31,8 +31,9 @@ public NavigationPermissionService(IResourceService resourceService, IUserGroupS /// The user. /// The loginWizardComplete. /// The controller name. + /// The current user id. /// The . - public async Task GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName) + public async Task GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName, int currentUserId) { if (!loginWizardComplete && (user.IsInRole("Administrator") || user.IsInRole("ReadOnly") || user.IsInRole("BlueUser") || user.IsInRole("BasicUser"))) { @@ -48,15 +49,15 @@ public async Task GetNavigationModelAsync(IPrincipal user, bool } else if (user.IsInRole("ReadOnly")) { - return await AuthenticatedReadOnly(controllerName,user.Identity.GetCurrentUserId()); + return await AuthenticatedReadOnly(controllerName, currentUserId); } else if (user.IsInRole("BasicUser")) { - return await AuthenticatedBasicUserOnly(user.Identity.GetCurrentUserId()); + return await AuthenticatedBasicUserOnly(currentUserId); } else if (user.IsInRole("BlueUser")) { - return await AuthenticatedBlueUser(controllerName, user.Identity.GetCurrentUserId()); + return await AuthenticatedBlueUser(controllerName, currentUserId); } else { diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/UserController.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/UserController.cs index dafb3b58..98590761 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/UserController.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Controllers/UserController.cs @@ -345,7 +345,7 @@ public async Task>> GetLHUserNavigation() var (cacheExists, _) = await this.cacheService.TryGetAsync($"{userId}:LoginWizard"); - model = await this.permissionService.GetNavigationModelAsync(this.User, !cacheExists, string.Empty); + model = await this.permissionService.GetNavigationModelAsync(this.User, !cacheExists, string.Empty, userId); model.NotificationCount = await this.userNotificationService.GetUserUnreadNotificationCountAsync(userId); }