|
|
|
@ -22,11 +22,19 @@ namespace Infrastructure.Extensions
|
|
|
|
|
httpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrincipal, new AuthenticationProperties { IsPersistent = rememberMe });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SignIn(this HttpContext httpContext, string userName, bool rememberMe, IConfiguration cfg, DateTime expires)
|
|
|
|
|
public static void SignIn(this HttpContext httpContext, string userName, bool rememberMe, IConfiguration cfg)
|
|
|
|
|
{
|
|
|
|
|
var token = httpContext.GetToken(userName, rememberMe, cfg, expires);
|
|
|
|
|
var token = httpContext.GetToken(userName, rememberMe, cfg, DateTime.Now.AddYears(1));
|
|
|
|
|
var cookieOptions = new CookieOptions
|
|
|
|
|
{
|
|
|
|
|
HttpOnly = true
|
|
|
|
|
};
|
|
|
|
|
if (rememberMe)
|
|
|
|
|
{
|
|
|
|
|
cookieOptions.Expires = DateTimeOffset.Now.AddYears(1);
|
|
|
|
|
}
|
|
|
|
|
httpContext.Response.Cookies.Delete("jwt");
|
|
|
|
|
httpContext.Response.Cookies.Append("jwt", token);
|
|
|
|
|
httpContext.Response.Cookies.Append("jwt", token, cookieOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetToken(this HttpContext httpContext, string userName, bool rememberMe, IConfiguration cfg, DateTime expires)
|
|
|
|
|