Asp.net mvc 如何在ASP.Net Identity 2中重写RefreshSign
有没有办法用ASP.NET Identity 2从ASP.NET Identity 3 SignInManager重写此方法Asp.net mvc 如何在ASP.Net Identity 2中重写RefreshSign,asp.net-mvc,asp.net-identity,asp.net-identity-2,asp.net-identity-3,Asp.net Mvc,Asp.net Identity,Asp.net Identity 2,Asp.net Identity 3,有没有办法用ASP.NET Identity 2从ASP.NET Identity 3 SignInManager重写此方法 // ///重新生成用户的应用程序cookie,同时保留现有的 ///身份验证属性,如rememberMe,作为异步操作。 /// ///应刷新其登录cookie的用户。 ///表示异步操作的任务对象。 公共虚拟异步任务RefreshSignInAsync(TUser用户) { var auth=新的AuthenticateContext(IdentityOption
//
///重新生成用户的应用程序cookie,同时保留现有的
///身份验证属性,如rememberMe,作为异步操作。
///
///应刷新其登录cookie的用户。
///表示异步操作的任务对象。
公共虚拟异步任务RefreshSignInAsync(TUser用户)
{
var auth=新的AuthenticateContext(IdentityOptions.ApplicationCookieAuthenticationScheme);
wait Context.Authentication.authenticateSync(auth);
var authenticationMethod=auth.Principal?.FindFirstValue(ClaimTypes.authenticationMethod);
等待签名同步(用户、新身份验证属性(auth.Properties)、身份验证方法);
}
/// <summary>
/// Regenerates the user's application cookie, whilst preserving the existing
/// AuthenticationProperties like rememberMe, as an asynchronous operation.
/// </summary>
/// <param name="user">The user whose sign-in cookie should be refreshed.</param>
/// <returns>The task object representing the asynchronous operation.</returns>
public virtual async Task RefreshSignInAsync(TUser user)
{
var auth = new AuthenticateContext(IdentityOptions.ApplicationCookieAuthenticationScheme);
await Context.Authentication.AuthenticateAsync(auth);
var authenticationMethod = auth.Principal?.FindFirstValue(ClaimTypes.AuthenticationMethod);
await SignInAsync(user, new AuthenticationProperties(auth.Properties), authenticationMethod);
}