Skip to content

Commit

Permalink
Merge pull request #1327 from DFE-Digital/bug/175300-logout-button-ac…
Browse files Browse the repository at this point in the history
…tion-fix

Fixed logout button action
  • Loading branch information
FrostyApeOne authored Aug 2, 2024
2 parents 08bebcf + 543a67f commit d8f84d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ConcernsCaseWork/ConcernsCaseWork/Pages/Logout.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@page
@model ConcernsCaseWork.Pages.LogoutModel
@{
}
25 changes: 25 additions & 0 deletions ConcernsCaseWork/ConcernsCaseWork/Pages/Logout.cshtml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using ConcernsCaseWork.Pages.Base;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using System.Threading.Tasks;

namespace ConcernsCaseWork.Pages
{
[Authorize]
public class LogoutModel : AbstractPageModel
{
public async Task<ActionResult> OnGetAsync()
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
{
RedirectUri = "/"
});
return Page();
}
}
}

0 comments on commit d8f84d2

Please sign in to comment.