|
20 | 20 | using LearningHub.Nhs.Auth.Models.Account; |
21 | 21 | using LearningHub.Nhs.Caching; |
22 | 22 | using LearningHub.Nhs.Models.Common; |
23 | | - using LearningHub.Nhs.Models.Entities.Reporting; |
24 | 23 | using Microsoft.AspNetCore.Authentication; |
25 | 24 | using Microsoft.AspNetCore.Authorization; |
26 | | - using Microsoft.AspNetCore.Http; |
27 | 25 | using Microsoft.AspNetCore.Mvc; |
28 | | - using Microsoft.Extensions.Configuration; |
29 | 26 | using Microsoft.Extensions.Logging; |
30 | 27 | using Microsoft.Extensions.Options; |
31 | | - using NHSUKViewComponents.Web.ViewModels; |
32 | 28 |
|
33 | 29 | /// <summary> |
34 | 30 | /// Account Controller operations. |
@@ -72,7 +68,7 @@ public AccountController( |
72 | 68 | this.authConfig = authConfig?.Value; |
73 | 69 | this.webSettings = webSettings; |
74 | 70 | this.logger = logger; |
75 | | - } |
| 71 | + } |
76 | 72 |
|
77 | 73 | /// <summary> |
78 | 74 | /// Shows the Login page. |
@@ -214,9 +210,9 @@ await this.UserService.AddLogonToUserHistory( |
214 | 210 | this.ModelState.AddModelError(string.Empty, loginResult.ErrorMessage); |
215 | 211 | } |
216 | 212 |
|
217 | | - showFormWithError: |
| 213 | +showFormWithError: |
218 | 214 |
|
219 | | - // something went wrong, show form with error |
| 215 | +// something went wrong, show form with error |
220 | 216 | var vm = await this.BuildLoginViewModelAsync(model); |
221 | 217 | if ((vm.ClientId == "learninghubwebclient") || (vm.ClientId == "learninghubadmin")) |
222 | 218 | { |
@@ -268,6 +264,9 @@ public async Task<IActionResult> Logout(LogoutInputModel model) |
268 | 264 | // delete local authentication cookie |
269 | 265 | await this.HttpContext.SignOutAsync(); |
270 | 266 |
|
| 267 | + // Delete the authentication cookie to ensure it is invalidated |
| 268 | + this.HttpContext.Response.Cookies.Delete(".AspNetCore.Identity.Application"); |
| 269 | + |
271 | 270 | // raise the logout event |
272 | 271 | await this.Events.RaiseAsync(new UserLogoutSuccessEvent(this.User.GetSubjectId(), this.User.GetDisplayName())); |
273 | 272 |
|
@@ -296,7 +295,15 @@ public async Task<IActionResult> Logout(LogoutInputModel model) |
296 | 295 | return this.SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme); |
297 | 296 | } |
298 | 297 |
|
299 | | - return this.View("LoggedOut", vm); |
| 298 | + if (this.webSettings.IsPasswordUpdate) |
| 299 | + { |
| 300 | + var redirectUri = $"{this.webSettings.LearningHubWebClient}Home/ChangePasswordAcknowledgement"; |
| 301 | + return this.Redirect(redirectUri); |
| 302 | + } |
| 303 | + else |
| 304 | + { |
| 305 | + return this.View("LoggedOut", vm); |
| 306 | + } |
300 | 307 | } |
301 | 308 |
|
302 | 309 | /// <summary> |
|
0 commit comments