로그인 코드 샘플

endpoints.MapGet("/Login", async context => 
{
    var claims = new List<Claim>
    {
        new Claim(ClaimTypes.Name, "아이디")
    };

    var claimsIdentity = new ClaimsIdentity(claims, "Cookies");

    var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);

    await context.SignInAsync("Cookies", claimsPrincipal);

    context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";
    await context.Response.WriteAsync("<h3>로그인 완료</h3>");
});

 

로그아웃 코드 샘플

endpoints.MapGet("/Logout", async context => 
{
    await context.SignOutAsync("Cookies");
    
    context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";
    await context.Response.WriteAsync("<h3>로그아웃 완료</h3>");
});

 

Comments


Comments are closed