refactor: 更新缓存逻辑

This commit is contained in:
Argo-Tianyi 2022-01-01 20:26:27 +08:00
parent b417eb04c8
commit e4cb1b4a9d
1 changed files with 11 additions and 1 deletions

View File

@ -57,7 +57,17 @@ namespace Bootstrap.Admin.Controllers
{
var identity = new ClaimsIdentity(authenticationScheme);
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { ExpiresUtc = DateTimeOffset.Now.AddDays(period), IsPersistent = persistent });
var properties = new AuthenticationProperties();
if (persistent)
{
properties.IsPersistent = true;
}
if (period != 0)
{
properties.ExpiresUtc = DateTimeOffset.Now.AddDays(period);
}
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), properties);
return Redirect(returnUrl ?? "/Home/Index");
}