public virtual async Task <ImpersonateOutput> DelegatedImpersonate(DelegatedImpersonateInput input) { var userDelegation = await _userDelegationManager.GetAsync(input.UserDelegationId); if (userDelegation.TargetUserId != AbpSession.GetUserId()) { throw new UserFriendlyException("User delegation error."); } return(new ImpersonateOutput { ImpersonationToken = await _impersonationManager.GetImpersonationToken(userDelegation.SourceUserId, userDelegation.TenantId), TenancyName = await GetTenancyNameOrNullAsync(userDelegation.TenantId) }); }
public virtual async Task <JsonResult> DelegatedImpersonate([FromBody] DelegatedImpersonateInput input) { var userDelegation = await _userDelegationManager.GetAsync(input.UserDelegationId); if (userDelegation.TargetUserId != AbpSession.GetUserId()) { throw new UserFriendlyException("User delegation error..."); } var output = await _accountAppService.Impersonate(new ImpersonateInput { TenantId = AbpSession.TenantId, UserId = userDelegation.SourceUserId }); await _signInManager.SignOutAsync(); return(Json(new AjaxResponse { TargetUrl = _webUrlService.GetSiteRootAddress(output.TenancyName) + "Account/DelegatedImpersonateSignIn?userDelegationId=" + input.UserDelegationId + "&tokenId=" + output.ImpersonationToken })); }