diff --git a/LearningHub.Nhs.WebUI/Controllers/HomeController.cs b/LearningHub.Nhs.WebUI/Controllers/HomeController.cs index ea18e6cd4..51d6be9db 100644 --- a/LearningHub.Nhs.WebUI/Controllers/HomeController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/HomeController.cs @@ -335,14 +335,19 @@ public IActionResult NhsSites() } /// - /// The Logout. - /// This is directly referenced in the LoginWizardFilter to allow - /// logouts to bypass LoginWizard redirects. - /// If the name is changed, the LoginWizardFilter MUST be updated. + /// The ChangePasswordAcknowledgement. /// /// The . - [AllowAnonymous] - public IActionResult Logout() + public IActionResult ChangePasswordAcknowledgement() + { + return this.View(); + } + + /// + /// StatusUpdate. + /// + /// Actionresult. + public IActionResult UserLogout() { if (!(this.User?.Identity.IsAuthenticated ?? false)) { @@ -352,6 +357,20 @@ public IActionResult Logout() return new SignOutResult(new[] { CookieAuthenticationDefaults.AuthenticationScheme, "oidc" }); } + /// + /// The Logout. + /// This is directly referenced in the LoginWizardFilter to allow + /// logouts to bypass LoginWizard redirects. + /// If the name is changed, the LoginWizardFilter MUST be updated. + /// + /// The . + [AllowAnonymous] + public IActionResult Logout() + { + var redirectUri = $"{this.configuration["LearningHubAuthServiceConfig:Authority"]}/Home/SetIsPasswordUpdate?isLogout=true"; + return this.Redirect(redirectUri); + } + /// /// The SessionTimeout. /// diff --git a/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs b/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs index 4494d9463..8711dd817 100644 --- a/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs +++ b/LearningHub.Nhs.WebUI/Controllers/MyAccountController.cs @@ -21,10 +21,12 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; + using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using NHSUKViewComponents.Web.ViewModels; using ChangePasswordViewModel = LearningHub.Nhs.WebUI.Models.UserProfile.ChangePasswordViewModel; + using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration; /// /// The UserController. @@ -43,6 +45,7 @@ public partial class MyAccountController : BaseController private readonly ISpecialtyService specialtyService; private readonly ILocationService locationService; private readonly ICacheService cacheService; + private readonly IConfiguration configuration; /// /// Initializes a new instance of the class. @@ -61,6 +64,7 @@ public partial class MyAccountController : BaseController /// The locationService. /// The multiPageFormService. /// The cacheService. + /// The cacheService. public MyAccountController( IWebHostEnvironment hostingEnvironment, ILogger logger, @@ -75,7 +79,8 @@ public MyAccountController( ISpecialtyService specialtyService, ILocationService locationService, IMultiPageFormService multiPageFormService, - ICacheService cacheService) + ICacheService cacheService, + IConfiguration configuration) : base(hostingEnvironment, httpClientFactory, logger, settings.Value) { this.userService = userService; @@ -88,6 +93,7 @@ public MyAccountController( this.locationService = locationService; this.multiPageFormService = multiPageFormService; this.cacheService = cacheService; + this.configuration = configuration; } private string LoginWizardCacheKey => $"{this.CurrentUserId}:LoginWizard"; @@ -452,9 +458,8 @@ public async Task UpdatePassword(ChangePasswordViewModel model) if (this.ModelState.IsValid) { await this.userService.UpdatePassword(model.NewPassword); - - this.ViewBag.SuccessMessage = CommonValidationErrorMessages.PasswordSuccessMessage; - return this.View("SuccessMessage"); + var redirectUri = $"{this.configuration["LearningHubAuthServiceConfig:Authority"]}/Home/SetIsPasswordUpdate?isLogout=false"; + return this.Redirect(redirectUri); } else { diff --git a/LearningHub.Nhs.WebUI/Views/Home/ChangePasswordAcknowledgement.cshtml b/LearningHub.Nhs.WebUI/Views/Home/ChangePasswordAcknowledgement.cshtml new file mode 100644 index 000000000..28bf1b66a --- /dev/null +++ b/LearningHub.Nhs.WebUI/Views/Home/ChangePasswordAcknowledgement.cshtml @@ -0,0 +1,24 @@ +@{ + ViewData["Title"] = "Change password Acknowledgement"; +} + + + + + + + Your password has been changed successfully. + + + You have been logged out. Please log in using your username and new password to explore the Learning Hub. + + + + Continue to the Learning Hub + + + + + + + \ No newline at end of file
+ You have been logged out. Please log in using your username and new password to explore the Learning Hub. +