Skip to content

Blazor Web Individual Account Template does not have the Logout form handler #51489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
Kumima opened this issue Oct 19, 2023 · 2 comments
Closed
1 task done
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@Kumima
Copy link

Kumima commented Oct 19, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Issue #51134 replace the LogoutForm into a standard post form. This can fix the problem that the LogoutForm won't work when nested in Interactive RenderMode, since it needs the HttpContext. The standard post form needs a form handler, but I did not find the endpoint definition of Account/Logout. Thre will be no handler for the logout form. If I get something wrong?

- <LogoutForm id="logout-form" />
- <NavLink class="nav-link" href="#" onclick="document.getElementById('logout-form').submit(); return false;">
-     <span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout
- </NavLink>
+ <form action="Account/Logout" method="post">
+   <AntiforgeryToken />
+     <input type="hidden" name="ReturnUrl" value="@currentUrl" />
+     <button type="submit" class="nav-link">
+         <span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout
+     </button>
+ </form>

Describe the solution you'd like

Add the needed form handler if there is something wrong. If not, point out the existing handler code location.

Additional context

No response

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Oct 19, 2023
@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us. This has already been fixed for the upcoming RTM release.

@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. ✔️ Resolution: Duplicate Resolved as a duplicate of another issue labels Oct 19, 2023
@ghost ghost added the Status: Resolved label Oct 19, 2023
@halter73
Copy link
Member

The standard post form needs a form handler, but I did not find the endpoint definition of Account/Logout. Thre will be no handler for the logout form. If I get something wrong?

The logout endpoint is defined using MapPost (Minimal APIs) in IdentityComponentsEndpointRouteBuilderExtensions along with a few other endpoints that support the Identity Razor components.

accountGroup.MapPost("/Logout", async (
ClaimsPrincipal user,
SignInManager<ApplicationUser> signInManager,
[FromForm] string returnUrl) =>
{
await signInManager.SignOutAsync();
return TypedResults.LocalRedirect($"~/{returnUrl}");
});

@ghost ghost locked as resolved and limited conversation to collaborators Nov 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants