Skip to content

Commit 64cb412

Browse files
TD-3734: Reverting the changes
1 parent 0f3403f commit 64cb412

File tree

9 files changed

+28
-197
lines changed

9 files changed

+28
-197
lines changed

AdminUI/LearningHub.Nhs.AdminUI/Controllers/api/UserController.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@
7878
</environment>
7979
@*<script type="text/javascript" src="~/js/bundle/header.js"></script>*@
8080
<partial name="~/Views/Shared/_ValidationScriptsPartial.cshtml" />
81-
8281
@RenderSection("Scripts", required: false)
83-
<script type="text/javascript" src="~/js/pageunload.js" asp-append-version="true"></script>
84-
<script type="text/javascript">
85-
// Bind the function to the unload event
86-
window.onunload = tellServerBrowserClosed;
87-
88-
</script>
8982
</body>
9083
</html>
9184
<!-- Build number: @settings.Value.BuildNumber -->

AdminUI/LearningHub.Nhs.AdminUI/wwwroot/js/PageUnload.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

LearningHub.Nhs.WebUI/Configuration/Settings.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ public Settings()
196196
/// </summary>
197197
public int PasswordRequestLimit { get; set; }
198198

199-
/// <summary>
200-
/// Gets or sets the ConcurrentId.
201-
/// </summary>
202-
public int ConcurrentId { get; set; }
203-
204199
/// <summary>
205200
/// Gets or sets the SupportUrls.
206201
/// </summary>

LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,6 @@ public async Task<IActionResult> CurrentProfile()
6363
return this.Ok(await this.userService.GetCurrentUserProfileAsync());
6464
}
6565

66-
/// <summary>
67-
/// The SessionTimeout.
68-
/// </summary>
69-
/// <returns>The <see cref="IActionResult"/>.</returns>
70-
[HttpPost("browser-close")]
71-
public IActionResult BrowserClose()
72-
{
73-
// Add browser close to the UserHistory
74-
UserHistoryViewModel userHistory = new UserHistoryViewModel()
75-
{
76-
UserId = this.CurrentUserId,
77-
UserHistoryTypeId = (int)UserHistoryType.Logout,
78-
Detail = @"User browser closed",
79-
};
80-
81-
this.userService.StoreUserHistory(userHistory);
82-
83-
return this.Ok(true);
84-
}
85-
8666
/// <summary>
8767
/// Get current user's basic details.
8868
/// </summary>

LearningHub.Nhs.WebUI/Controllers/HomeController.cs

Lines changed: 28 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace LearningHub.Nhs.WebUI.Controllers
66
using System.Linq;
77
using System.Net.Http;
88
using System.Threading.Tasks;
9-
using AspNetCoreRateLimit;
109
using elfhHub.Nhs.Models.Common;
1110
using elfhHub.Nhs.Models.Enums;
1211
using LearningHub.Nhs.Models.Content;
@@ -27,7 +26,6 @@ namespace LearningHub.Nhs.WebUI.Controllers
2726
using Microsoft.Extensions.Logging;
2827
using Microsoft.Extensions.Options;
2928
using Microsoft.FeatureManagement;
30-
using UAParser;
3129
using Settings = LearningHub.Nhs.WebUI.Configuration.Settings;
3230

3331
/// <summary>
@@ -208,54 +206,42 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
208206
{
209207
if (this.User?.Identity.IsAuthenticated == true)
210208
{
211-
var userHistoryDetail = await this.userService.CheckUserHasAnActiveSessionAsync(this.CurrentUserId);
212-
var uaParser = Parser.GetDefault();
213-
var clientInfo = uaParser.Parse(this.Request.Headers["User-Agent"]);
214-
215-
if (userHistoryDetail.Items.Count == 0 || userHistoryDetail.Items[0].BrowserName == clientInfo.UA.Family)
209+
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
210+
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
216211
{
217-
this.Settings.ConcurrentId = this.CurrentUserId;
218-
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
219-
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
212+
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
213+
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
214+
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);
215+
216+
var enrolledCoursesTask = Task.FromResult(new List<MoodleCourseResponseViewModel>());
217+
var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
218+
this.ViewBag.EnableMoodle = enableMoodle;
219+
this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
220+
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
220221
{
221-
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
222-
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
223-
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);
224-
225-
var enrolledCoursesTask = Task.FromResult(new List<MoodleCourseResponseViewModel>());
226-
var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
227-
this.ViewBag.EnableMoodle = enableMoodle;
228-
this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
229-
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
230-
{
231-
enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(this.CurrentMoodleUserId, 1);
232-
}
233-
234-
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);
235-
236-
var model = new DashboardViewModel()
237-
{
238-
MyLearnings = await learningTask,
239-
Resources = await resourcesTask,
240-
Catalogues = await cataloguesTask,
241-
EnrolledCourses = await enrolledCoursesTask,
242-
};
243-
244-
if (!string.IsNullOrEmpty(this.Request.Query["preview"]) && Convert.ToBoolean(this.Request.Query["preview"]))
245-
{
246-
return this.View("LandingPage", await this.GetLandingPageContent(Convert.ToBoolean(this.Request.Query["preview"])));
247-
}
248-
249-
return this.View("Dashboard", model);
222+
enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(this.CurrentMoodleUserId, 1);
250223
}
251-
else
224+
225+
await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);
226+
227+
var model = new DashboardViewModel()
228+
{
229+
MyLearnings = await learningTask,
230+
Resources = await resourcesTask,
231+
Catalogues = await cataloguesTask,
232+
EnrolledCourses = await enrolledCoursesTask,
233+
};
234+
235+
if (!string.IsNullOrEmpty(this.Request.Query["preview"]) && Convert.ToBoolean(this.Request.Query["preview"]))
252236
{
253-
return this.RedirectToAction("InvalidUserAccount", "Account");
237+
return this.View("LandingPage", await this.GetLandingPageContent(Convert.ToBoolean(this.Request.Query["preview"])));
254238
}
239+
240+
return this.View("Dashboard", model);
255241
}
256242
else
257243
{
258-
return this.RedirectToAction("AlreadyAnActiveSession", "Account");
244+
return this.RedirectToAction("InvalidUserAccount", "Account");
259245
}
260246
}
261247
else
@@ -399,41 +385,12 @@ public IActionResult SessionTimeout(string returnUrl = "/")
399385
return this.Redirect(returnUrl);
400386
}
401387

402-
// Add successful logout to the UserHistory
403-
UserHistoryViewModel userHistory = new UserHistoryViewModel()
404-
{
405-
UserId = this.Settings.ConcurrentId,
406-
UserHistoryTypeId = (int)UserHistoryType.Logout,
407-
Detail = @"User session time out",
408-
};
409-
410-
this.userService.StoreUserHistory(userHistory);
411-
412388
this.ViewBag.AuthTimeout = this.authConfig.AuthTimeout;
413389
this.ViewBag.ReturnUrl = returnUrl;
414390

415391
return this.View();
416392
}
417393

418-
/// <summary>
419-
/// The SessionTimeout.
420-
/// </summary>
421-
/// <returns>The <see cref="IActionResult"/>.</returns>
422-
[HttpPost("browser-close")]
423-
public IActionResult BrowserClose()
424-
{
425-
// Add browser close to the UserHistory
426-
UserHistoryViewModel userHistory = new UserHistoryViewModel()
427-
{
428-
UserId = this.CurrentUserId,
429-
UserHistoryTypeId = (int)UserHistoryType.Logout,
430-
Detail = @"User browser closed",
431-
};
432-
433-
this.userService.StoreUserHistory(userHistory);
434-
return this.Ok(true);
435-
}
436-
437394
/// <summary>
438395
/// The SitemapXml.
439396
/// </summary>

LearningHub.Nhs.WebUI/Views/Shared/Tenant/LearningHub/_Layout.cshtml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,6 @@
161161
@RenderSection("Scripts", required: false)
162162

163163
<script type="text/javascript" src="~/js/mkplayer-ui-custom.js" asp-append-version="true"></script>
164-
<script type="text/javascript" src="~/js/pageunload.js" asp-append-version="true"></script>
165-
166-
<script type="text/javascript">
167-
// Bind the function to the unload event
168-
window.onunload = tellServerBrowserClosed;
169-
170-
</script>
171164

172165
</body>
173166
</html>

LearningHub.Nhs.WebUI/appsettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"Restricted": false,
4040
"PasswordRequestLimitingPeriod": 1, // minutes
4141
"PasswordRequestLimit": 2,
42-
"ConcurrentId": 0,
4342
"AzureBlobSettings": {
4443
"ConnectionString": "",
4544
"UploadContainer": ""

LearningHub.Nhs.WebUI/wwwroot/js/PageUnload.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)