Skip to content

Commit b28c7bd

Browse files
Merge pull request #1485 from TechnologyEnhancedLearning/Develop/Fixes/TD-6342-Issue-missing-the-'My-contributions'-link-on-Moodle-test-env-for-some-users
TD-6342: Created a new parameter to pass the current user id so to get the menu items for moodle header.
2 parents 26d3f36 + eb4f11a commit b28c7bd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/INavigationPermissionService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public interface INavigationPermissionService
1515
/// <param name="user">User.</param>
1616
/// <param name="loginWizardComplete">Login wizard complete.</param>
1717
/// <param name="controllerName">Controller name.</param>
18+
/// <param name="currentUserId">The current user id.</param>
1819
/// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
19-
Task<NavigationModel> GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName);
20+
Task<NavigationModel> GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName, int currentUserId);
2021

2122
/// <summary>
2223
/// The NotAuthenticated.

OpenAPI/LearningHub.Nhs.OpenApi.Services/Services/NavigationPermissionService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ public NavigationPermissionService(IResourceService resourceService, IUserGroupS
3131
/// <param name="user">The user<see cref="IPrincipal"/>.</param>
3232
/// <param name="loginWizardComplete">The loginWizardComplete<see cref="bool"/>.</param>
3333
/// <param name="controllerName">The controller name.</param>
34+
/// <param name="currentUserId">The current user id.</param>
3435
/// <returns>The <see cref="Task{NavigationModel}"/>.</returns>
35-
public async Task<NavigationModel> GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName)
36+
public async Task<NavigationModel> GetNavigationModelAsync(IPrincipal user, bool loginWizardComplete, string controllerName, int currentUserId)
3637
{
3738
if (!loginWizardComplete && (user.IsInRole("Administrator") || user.IsInRole("ReadOnly") || user.IsInRole("BlueUser") || user.IsInRole("BasicUser")))
3839
{
@@ -48,15 +49,15 @@ public async Task<NavigationModel> GetNavigationModelAsync(IPrincipal user, bool
4849
}
4950
else if (user.IsInRole("ReadOnly"))
5051
{
51-
return await AuthenticatedReadOnly(controllerName,user.Identity.GetCurrentUserId());
52+
return await AuthenticatedReadOnly(controllerName, currentUserId);
5253
}
5354
else if (user.IsInRole("BasicUser"))
5455
{
55-
return await AuthenticatedBasicUserOnly(user.Identity.GetCurrentUserId());
56+
return await AuthenticatedBasicUserOnly(currentUserId);
5657
}
5758
else if (user.IsInRole("BlueUser"))
5859
{
59-
return await AuthenticatedBlueUser(controllerName, user.Identity.GetCurrentUserId());
60+
return await AuthenticatedBlueUser(controllerName, currentUserId);
6061
}
6162
else
6263
{

OpenAPI/LearningHub.Nhs.OpenApi/Controllers/UserController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public async Task<List<Dictionary<string, object>>> GetLHUserNavigation()
345345

346346
var (cacheExists, _) = await this.cacheService.TryGetAsync<string>($"{userId}:LoginWizard");
347347

348-
model = await this.permissionService.GetNavigationModelAsync(this.User, !cacheExists, string.Empty);
348+
model = await this.permissionService.GetNavigationModelAsync(this.User, !cacheExists, string.Empty, userId);
349349

350350
model.NotificationCount = await this.userNotificationService.GetUserUnreadNotificationCountAsync(userId);
351351
}

0 commit comments

Comments
 (0)