Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2599017
Bump webpack from 5.99.5 to 5.99.6 in /Auth/LearningHub.Nhs.Auth (#159)
dependabot[bot] Apr 21, 2025
e8b48a1
Bump sass from 1.86.3 to 1.87.0 in /Auth/LearningHub.Nhs.Auth (#160)
dependabot[bot] Apr 22, 2025
406db4e
Bump webpack from 5.99.6 to 5.99.7 in /Auth/LearningHub.Nhs.Auth (#163)
dependabot[bot] Apr 28, 2025
d8146cb
Bump core-js from 3.41.0 to 3.42.0 in /Auth/LearningHub.Nhs.Auth
dependabot[bot] Apr 30, 2025
280f58b
Bump @babel/preset-env in /Auth/LearningHub.Nhs.Auth (#166)
dependabot[bot] May 1, 2025
e30680a
Bump @babel/core from 7.26.10 to 7.27.1 in /Auth/LearningHub.Nhs.Auth…
dependabot[bot] May 1, 2025
806e71b
Bump @babel/preset-env in /Auth/LearningHub.Nhs.Auth (#168)
dependabot[bot] May 7, 2025
de4f408
Bump webpack from 5.99.7 to 5.99.8 in /Auth/LearningHub.Nhs.Auth (#169)
dependabot[bot] May 7, 2025
dcf647a
Merge pull request #165 from TechnologyEnhancedLearning/dependabot/np…
AnjuJose011 May 7, 2025
ad7eacc
Bump node from 22.14.0 to 22.15.0 in /Auth/LearningHub.Nhs.Auth
dependabot[bot] May 7, 2025
b2a635d
Merge pull request #161 from TechnologyEnhancedLearning/dependabot/np…
AnjuJose011 May 7, 2025
904b197
Bump sass from 1.87.0 to 1.88.0 in /Auth/LearningHub.Nhs.Auth (#170)
dependabot[bot] May 12, 2025
8f110d0
Bump sass from 1.88.0 to 1.89.0 in /Auth/LearningHub.Nhs.Auth (#174)
dependabot[bot] May 16, 2025
0084b1e
Bump node from 22.15.0 to 22.15.1 in /Auth/LearningHub.Nhs.Auth
dependabot[bot] May 16, 2025
336c139
Merge pull request #172 from TechnologyEnhancedLearning/dependabot/np…
AnjuJose011 May 16, 2025
9922fe0
Bump webpack from 5.99.8 to 5.99.9 in /Auth/LearningHub.Nhs.Auth (#176)
dependabot[bot] May 21, 2025
18ae9fb
Bump node from 22.15.1 to 22.16.0 in /Auth/LearningHub.Nhs.Auth
dependabot[bot] May 22, 2025
4da634d
Merge pull request #177 from TechnologyEnhancedLearning/dependabot/np…
AnjuJose011 May 22, 2025
b8c36d4
Merge pull request #179 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 May 27, 2025
d9e5cdb
Bump @babel/core from 7.27.1 to 7.27.3 in /Auth/LearningHub.Nhs.Auth …
dependabot[bot] May 28, 2025
0f43fca
TD-3734: Reverting the changes
swapnamol-abraham May 28, 2025
840154c
Merge pull request #181 from TechnologyEnhancedLearning/Develop/Fixes…
AnjuJose011 May 28, 2025
2f2a73d
Merge pull request #182 from TechnologyEnhancedLearning/Automatic_ver…
AnjuJose011 May 29, 2025
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
55 changes: 21 additions & 34 deletions Auth/LearningHub.Nhs.Auth/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Azure.Core;
using elfhHub.Nhs.Models.Common;
using elfhHub.Nhs.Models.Enums;
using IdentityModel;
Expand All @@ -23,11 +22,9 @@
using LearningHub.Nhs.Models.Common;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using UAParser;

/// <summary>
/// Account Controller operations.
Expand Down Expand Up @@ -166,44 +163,34 @@ await this.interaction.GrantConsentAsync(

if (loginResult.IsAuthenticated)
{
var uaParser = Parser.GetDefault();
var clientInfo = uaParser.Parse(this.Request.Headers["User-Agent"]);
var result = await this.UserService.CheckUserHasAnActiveSessionAsync(userId);
if (result.Items.Count == 0 || result.Items[0].BrowserName == clientInfo.UA.Family)
{
await this.SignInUser(userId, model.Username.Trim(), model.RememberLogin, context.Parameters["ext_referer"]);
await this.SignInUser(userId, model.Username.Trim(), model.RememberLogin, context.Parameters["ext_referer"]);

if (context != null)
if (context != null)
{
if (await this.ClientStore.IsPkceClientAsync(context.Client.ClientId))
{
if (await this.ClientStore.IsPkceClientAsync(context.Client.ClientId))
{
// if the client is PKCE then we assume it's native, so this change in how to
// return the response is for better UX for the end user.
return this.View("Redirect", new RedirectViewModel { RedirectUrl = model.ReturnUrl });
}

// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
return this.Redirect(model.ReturnUrl);
// if the client is PKCE then we assume it's native, so this change in how to
// return the response is for better UX for the end user.
return this.View("Redirect", new RedirectViewModel { RedirectUrl = model.ReturnUrl });
}

// request for a local page
if (this.Url.IsLocalUrl(model.ReturnUrl))
{
return this.Redirect(model.ReturnUrl);
}
else if (string.IsNullOrEmpty(model.ReturnUrl))
{
return this.Redirect("~/");
}
else
{
// user might have clicked on a malicious link - should be logged
throw new Exception("invalid return URL");
}
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
return this.Redirect(model.ReturnUrl);
}

// request for a local page
if (this.Url.IsLocalUrl(model.ReturnUrl))
{
return this.Redirect(model.ReturnUrl);
}
else if (string.IsNullOrEmpty(model.ReturnUrl))
{
return this.Redirect("~/");
}
else
{
return this.View("AlreadyActiveSession");
// user might have clicked on a malicious link - should be logged
throw new Exception("invalid return URL");
}
}
else if (userId > 0)
Expand Down
7 changes: 0 additions & 7 deletions Auth/LearningHub.Nhs.Auth/Interfaces/IUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ public interface IUserService
/// </returns>
Task StoreUserHistoryAsync(UserHistoryViewModel userHistory);

/// <summary>
/// check user has an laredy active session.
/// </summary>
/// <param name="userId">The userId.</param>
/// <returns>The <see cref="Task"/>.</returns>
Task<PagedResultSet<UserHistoryViewModel>> CheckUserHasAnActiveSessionAsync(int userId);

/// <summary>
/// The store user history async.
/// </summary>
Expand Down
24 changes: 0 additions & 24 deletions Auth/LearningHub.Nhs.Auth/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,29 +243,5 @@ public async Task StoreUserHistoryAsync(UserHistoryViewModel userHistory)
}
}
}

/// <inheritdoc/>
public async Task<PagedResultSet<UserHistoryViewModel>> CheckUserHasAnActiveSessionAsync(int userId)
{
PagedResultSet<UserHistoryViewModel> userHistoryViewModel = new PagedResultSet<UserHistoryViewModel>();

var client = this.UserApiHttpClient.GetClient();
var request = $"UserHistory/CheckUserHasActiveSession/{userId}";
var response = await client.GetAsync(request).ConfigureAwait(false);

if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsStringAsync();
userHistoryViewModel = JsonConvert.DeserializeObject<PagedResultSet<UserHistoryViewModel>>(result);
}
else if (response.StatusCode == HttpStatusCode.Unauthorized
||
response.StatusCode == HttpStatusCode.Forbidden)
{
throw new Exception("AccessDenied");
}

return userHistoryViewModel;
}
}
}

This file was deleted.

Loading
Loading