Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions AdminUI/LearningHub.Nhs.AdminUI/Controllers/api/UserController.cs

This file was deleted.

7 changes: 0 additions & 7 deletions AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,7 @@
</environment>
@*<script type="text/javascript" src="~/js/bundle/header.js"></script>*@
<partial name="~/Views/Shared/_ValidationScriptsPartial.cshtml" />

@RenderSection("Scripts", required: false)
<script type="text/javascript" src="~/js/pageunload.js" asp-append-version="true"></script>
<script type="text/javascript">
// Bind the function to the unload event
window.onunload = tellServerBrowserClosed;
</script>
</body>
</html>
<!-- Build number: @settings.Value.BuildNumber -->
Expand Down
13 changes: 0 additions & 13 deletions AdminUI/LearningHub.Nhs.AdminUI/wwwroot/js/PageUnload.js

This file was deleted.

5 changes: 0 additions & 5 deletions LearningHub.Nhs.WebUI/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ public Settings()
/// </summary>
public int PasswordRequestLimit { get; set; }

/// <summary>
/// Gets or sets the ConcurrentId.
/// </summary>
public int ConcurrentId { get; set; }

/// <summary>
/// Gets or sets the SupportUrls.
/// </summary>
Expand Down
20 changes: 0 additions & 20 deletions LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,6 @@ public async Task<IActionResult> CurrentProfile()
return this.Ok(await this.userService.GetCurrentUserProfileAsync());
}

/// <summary>
/// The SessionTimeout.
/// </summary>
/// <returns>The <see cref="IActionResult"/>.</returns>
[HttpPost("browser-close")]
public IActionResult BrowserClose()
{
// Add browser close to the UserHistory
UserHistoryViewModel userHistory = new UserHistoryViewModel()
{
UserId = this.CurrentUserId,
UserHistoryTypeId = (int)UserHistoryType.Logout,
Detail = @"User browser closed",
};

this.userService.StoreUserHistory(userHistory);

return this.Ok(true);
}

/// <summary>
/// Get current user's basic details.
/// </summary>
Expand Down
99 changes: 28 additions & 71 deletions LearningHub.Nhs.WebUI/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace LearningHub.Nhs.WebUI.Controllers
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using AspNetCoreRateLimit;
using elfhHub.Nhs.Models.Common;
using elfhHub.Nhs.Models.Enums;
using LearningHub.Nhs.Models.Content;
Expand All @@ -27,7 +26,6 @@ namespace LearningHub.Nhs.WebUI.Controllers
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.FeatureManagement;
using UAParser;
using Settings = LearningHub.Nhs.WebUI.Configuration.Settings;

/// <summary>
Expand Down Expand Up @@ -208,54 +206,42 @@ public async Task<IActionResult> Index(string myLearningDashboard = "my-in-progr
{
if (this.User?.Identity.IsAuthenticated == true)
{
var userHistoryDetail = await this.userService.CheckUserHasAnActiveSessionAsync(this.CurrentUserId);
var uaParser = Parser.GetDefault();
var clientInfo = uaParser.Parse(this.Request.Headers["User-Agent"]);

if (userHistoryDetail.Items.Count == 0 || userHistoryDetail.Items[0].BrowserName == clientInfo.UA.Family)
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
{
this.Settings.ConcurrentId = this.CurrentUserId;
this.Logger.LogInformation("User is authenticated: User is {fullname} and userId is: {lhuserid}", this.User.Identity.GetCurrentName(), this.User.Identity.GetCurrentUserId());
if (this.User.IsInRole("Administrator") || this.User.IsInRole("BlueUser") || this.User.IsInRole("ReadOnly") || this.User.IsInRole("BasicUser"))
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);

var enrolledCoursesTask = Task.FromResult(new List<MoodleCourseResponseViewModel>());
var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
this.ViewBag.EnableMoodle = enableMoodle;
this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
{
var learningTask = this.dashboardService.GetMyAccessLearningsAsync(myLearningDashboard, 1);
var resourcesTask = this.dashboardService.GetResourcesAsync(resourceDashboard, 1);
var cataloguesTask = this.dashboardService.GetCataloguesAsync(catalogueDashboard, 1);

var enrolledCoursesTask = Task.FromResult(new List<MoodleCourseResponseViewModel>());
var enableMoodle = Task.Run(() => this.featureManager.IsEnabledAsync(FeatureFlags.EnableMoodle)).Result;
this.ViewBag.EnableMoodle = enableMoodle;
this.ViewBag.ValidMoodleUser = this.CurrentMoodleUserId > 0;
if (enableMoodle && myLearningDashboard == "my-enrolled-courses")
{
enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(this.CurrentMoodleUserId, 1);
}

await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);

var model = new DashboardViewModel()
{
MyLearnings = await learningTask,
Resources = await resourcesTask,
Catalogues = await cataloguesTask,
EnrolledCourses = await enrolledCoursesTask,
};

if (!string.IsNullOrEmpty(this.Request.Query["preview"]) && Convert.ToBoolean(this.Request.Query["preview"]))
{
return this.View("LandingPage", await this.GetLandingPageContent(Convert.ToBoolean(this.Request.Query["preview"])));
}

return this.View("Dashboard", model);
enrolledCoursesTask = this.dashboardService.GetEnrolledCoursesFromMoodleAsync(this.CurrentMoodleUserId, 1);
}
else

await Task.WhenAll(learningTask, resourcesTask, cataloguesTask);

var model = new DashboardViewModel()
{
MyLearnings = await learningTask,
Resources = await resourcesTask,
Catalogues = await cataloguesTask,
EnrolledCourses = await enrolledCoursesTask,
};

if (!string.IsNullOrEmpty(this.Request.Query["preview"]) && Convert.ToBoolean(this.Request.Query["preview"]))
{
return this.RedirectToAction("InvalidUserAccount", "Account");
return this.View("LandingPage", await this.GetLandingPageContent(Convert.ToBoolean(this.Request.Query["preview"])));
}

return this.View("Dashboard", model);
}
else
{
return this.RedirectToAction("AlreadyAnActiveSession", "Account");
return this.RedirectToAction("InvalidUserAccount", "Account");
}
}
else
Expand Down Expand Up @@ -399,41 +385,12 @@ public IActionResult SessionTimeout(string returnUrl = "/")
return this.Redirect(returnUrl);
}

// Add successful logout to the UserHistory
UserHistoryViewModel userHistory = new UserHistoryViewModel()
{
UserId = this.Settings.ConcurrentId,
UserHistoryTypeId = (int)UserHistoryType.Logout,
Detail = @"User session time out",
};

this.userService.StoreUserHistory(userHistory);

this.ViewBag.AuthTimeout = this.authConfig.AuthTimeout;
this.ViewBag.ReturnUrl = returnUrl;

return this.View();
}

/// <summary>
/// The SessionTimeout.
/// </summary>
/// <returns>The <see cref="IActionResult"/>.</returns>
[HttpPost("browser-close")]
public IActionResult BrowserClose()
{
// Add browser close to the UserHistory
UserHistoryViewModel userHistory = new UserHistoryViewModel()
{
UserId = this.CurrentUserId,
UserHistoryTypeId = (int)UserHistoryType.Logout,
Detail = @"User browser closed",
};

this.userService.StoreUserHistory(userHistory);
return this.Ok(true);
}

/// <summary>
/// The SitemapXml.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@
@RenderSection("Scripts", required: false)

<script type="text/javascript" src="~/js/mkplayer-ui-custom.js" asp-append-version="true"></script>
<script type="text/javascript" src="~/js/pageunload.js" asp-append-version="true"></script>

<script type="text/javascript">
// Bind the function to the unload event
window.onunload = tellServerBrowserClosed;

</script>

</body>
</html>
Expand Down
1 change: 0 additions & 1 deletion LearningHub.Nhs.WebUI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"Restricted": false,
"PasswordRequestLimitingPeriod": 1, // minutes
"PasswordRequestLimit": 2,
"ConcurrentId": 0,
"AzureBlobSettings": {
"ConnectionString": "",
"UploadContainer": ""
Expand Down
13 changes: 0 additions & 13 deletions LearningHub.Nhs.WebUI/wwwroot/js/PageUnload.js

This file was deleted.

Loading