Make server-side Blazor template logout use POST. Fixes #11981 (#12419)

This commit is contained in:
Steve Sanderson 2019-07-21 17:20:46 -07:00 committed by GitHub
parent 36a651e29a
commit e043f9317f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -1,8 +1,9 @@
@page
@using Microsoft.AspNetCore.Identity
@attribute [IgnoreAntiforgeryToken]
@inject SignInManager<IdentityUser> SignInManager
@functions {
public async Task<IActionResult> OnGet()
public async Task<IActionResult> OnPost()
{
if (SignInManager.IsSignedIn(User))
{

View File

@ -1,7 +1,9 @@
<AuthorizeView>
<Authorized>
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
<a href="Identity/Account/LogOut">Log out</a>
<form method="post" action="Identity/Account/LogOut">
<button type="submit" class="nav-link btn btn-link">Log out</button>
</form>
</Authorized>
<NotAuthorized>
<a href="Identity/Account/Register">Register</a>

View File

@ -4,7 +4,7 @@ html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
a {
a, .btn-link {
color: #0366d6;
}