public async Task LinkToUser(LinkToUserInput input) { var loginResult = await _logInManager.LoginAsync(input.UsernameOrEmailAddress, input.Password, input.TenancyName); if (loginResult.Result != AbpLoginResultType.Success) { throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(loginResult.Result, input.UsernameOrEmailAddress, input.TenancyName); } if (AbpSession.IsUser(loginResult.User)) { throw new UserFriendlyException(L("YouCannotLinkToSameAccount")); } if (loginResult.User.ShouldChangePasswordOnNextLogin) { throw new UserFriendlyException(L("ChangePasswordBeforeLinkToAnAccount")); } await _userLinkManager.Link(GetCurrentUser(), loginResult.User); }
public async Task LinkToUser(LinkToUserInput input) { using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.MayHaveTenant)) { var loginResult = await UserManager.LoginAsync(input.UsernameOrEmailAddress, input.Password, input.TenancyName); if (loginResult.Result != AbpLoginResultType.Success) { throw _abpLoginResultTypeHelper.CreateExceptionForFailedLoginAttempt(loginResult.Result, input.UsernameOrEmailAddress, input.TenancyName); } if (loginResult.User.Id == AbpSession.GetUserId()) { throw new UserFriendlyException(L("YouCannotLinkToSameAccount")); } if (loginResult.User.ShouldChangePasswordOnNextLogin) { throw new UserFriendlyException(L("ChangePasswordBeforeLinkToAnAccount")); } await _userLinkManager.Link(AbpSession.GetUserId(), loginResult.User.Id); } }