30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using RobotApp.Data;
|
|
using System.Security.Claims;
|
|
|
|
namespace Microsoft.AspNetCore.Routing
|
|
{
|
|
internal static class IdentityComponentsEndpointRouteBuilderExtensions
|
|
{
|
|
// These endpoints are required by the Identity Razor components defined in the /Components/Account/Pages directory of this project.
|
|
public static IEndpointConventionBuilder MapAdditionalIdentityEndpoints(this IEndpointRouteBuilder endpoints)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(endpoints);
|
|
|
|
var accountGroup = endpoints.MapGroup("/Account");
|
|
|
|
accountGroup.MapPost("/Logout", async (
|
|
ClaimsPrincipal user,
|
|
SignInManager<ApplicationUser> signInManager,
|
|
[FromForm] string returnUrl) =>
|
|
{
|
|
await signInManager.SignOutAsync();
|
|
return TypedResults.LocalRedirect($"~/{returnUrl}");
|
|
});
|
|
|
|
return accountGroup;
|
|
}
|
|
}
|
|
}
|