diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Controllers/AuthorizationController.cs b/dotnet-authserver/src/TeacherIdentity.AuthServer/Controllers/AuthorizationController.cs index de1f11983..c40ac372b 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Controllers/AuthorizationController.cs +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Controllers/AuthorizationController.cs @@ -405,13 +405,17 @@ public async Task Exchange() [ActionName(nameof(SignOut)), HttpPost("~/connect/signout")] public async Task SignOutPost() { + var redirectUri = HttpContext.TryGetAuthenticationState(out var authenticationState) ? + authenticationState.PostSignInUrl : + "/"; + await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); return SignOut( authenticationSchemes: OpenIddictServerAspNetCoreDefaults.AuthenticationScheme, properties: new AuthenticationProperties { - RedirectUri = "/" + RedirectUri = redirectUri }); } diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Account/_Layout.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Account/_Layout.cshtml index a61d7d124..1b66a1e3e 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Account/_Layout.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/Account/_Layout.cshtml @@ -1,19 +1,6 @@ @{ ViewBag.ServiceUrl = LinkGenerator.Account(Context.GetClientRedirectInfo()); Layout = "/Views/Shared/_Layout.cshtml"; - - var signOutUrl = Context.GetClientRedirectInfo()?.SignOutUri ?? LinkGenerator.SignOut(); -} - -@section HeaderNav { - } @section BeforeContent { diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Complete.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Complete.cshtml index fa9ea7ad8..4dccef1e2 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Complete.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Pages/SignIn/Complete.cshtml @@ -24,8 +24,6 @@ } } - var signOutLink = LinkGenerator.SignOut(); - async Task RenderContent() { @@ -135,17 +133,6 @@ } } -@section HeaderNav { - -} - @if (Model.CanAccessService) {
diff --git a/dotnet-authserver/src/TeacherIdentity.AuthServer/Views/Shared/_Layout.cshtml b/dotnet-authserver/src/TeacherIdentity.AuthServer/Views/Shared/_Layout.cshtml index b352c13e2..9a45422f5 100644 --- a/dotnet-authserver/src/TeacherIdentity.AuthServer/Views/Shared/_Layout.cshtml +++ b/dotnet-authserver/src/TeacherIdentity.AuthServer/Views/Shared/_Layout.cshtml @@ -1,4 +1,5 @@ @using TeacherIdentity.AuthServer.Journeys; +@using Microsoft.AspNetCore.Authentication; @inject TeacherIdentity.AuthServer.Oidc.ICurrentClientProvider CurrentClientProvider @inject ClientScopedViewHelper ClientScopedViewHelper @inject SignInJourneyProvider SignInJourneyProvider @@ -13,6 +14,9 @@ var serviceName = ViewBag.ServiceName ?? "DfE Identity account"; var serviceUrl = ViewBag.ServiceUrl ?? "/"; + + var isSignedIn = (await Context.AuthenticateAsync(Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationDefaults.AuthenticationScheme)).Succeeded; + var signOutLink = Context.GetClientRedirectInfo()?.SignOutUri ?? LinkGenerator.SignOut(); } @section Head { @@ -45,7 +49,25 @@ @serviceName - @RenderSection("HeaderNav", required: false) + + @if (IsSectionDefined("HeaderNav")) + { + @RenderSection("HeaderNav") + } + else + { + @if (isSignedIn) + { + + } + } @@ -55,13 +77,13 @@ @RenderSection("BeforeContent", required: false) } -@if (TempData.TryGetFlashSuccess(out (string heading, string? message)? flashSuccess)) +@if (TempData.TryGetFlashSuccess(out (string Heading, string? Message)? flashSuccess)) { -

@flashSuccess.Value.heading

- @if (flashSuccess.Value.message is not null) +

@flashSuccess.Value.Heading

+ @if (flashSuccess.Value.Message is not null) { - @foreach (var line in flashSuccess.Value.message.Split(Environment.NewLine)) + @foreach (var line in flashSuccess.Value.Message.Split(Environment.NewLine)) { @line
}