110,537
社区成员
发帖
与我相关
我的任务
分享
public void SignIn(string token, string name)
{
ClaimsIdentity claimsIdentity = new ClaimsIdentity(CookieUsrAuthInfo.AuthenticationScheme);
claimsIdentity.AddClaim(new Claim(ClaimTypes.NameIdentifier, token));
claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, name));
ClaimsPrincipal claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
_httpContextAccessor.HttpContext.SignInAsync(CookieUsrAuthInfo.AuthenticationScheme, claimsPrincipal);
}
public SysUserAccount GetCurrentUser()
{
var result = _httpContextAccessor.HttpContext.AuthenticateAsync(CookieUsrAuthInfo.AuthenticationScheme).Result;
var token = result.Principal.FindFirstValue(ClaimTypes.Sid);
return _sysUserAccountService.GetLogged(token);
}
var getUsr = _userAuthService.GetCurrentUser();