public async Task LinkToUser(LinkToUserInput input)
        {
            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 (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 Should_Link_User_To_Already_Linked_User()
        {
            //Arrange
            LoginAsHostAdmin();
            await CreateTestTenantAndTestUser();

            LoginAsDefaultTenantAdmin();
            await CreateTestUsersForAccountLinkingAsync();

            var linkToTestTenantUserInput = new LinkToUserInput
            {
                TenancyName = "Test",
                UsernameOrEmailAddress = "test",
                Password = "******"
            };

            //Act
            //Link Default\admin -> Test\test
            await _userLinkAppService.LinkToUser(linkToTestTenantUserInput);

            LoginAsTenant(Tenant.DefaultTenantName, "jnash");
            //Link Default\jnash->Test\test
            await _userLinkAppService.LinkToUser(linkToTestTenantUserInput);

            //Assert
            await UsingDbContextAsync(async context =>
            {
                var defaultTenantAdmin = await context.Users.FirstOrDefaultAsync(u => u.Id == AbpSession.UserId);
                var defaultTenantAdminAccount = await _userLinkManager.GetUserAccountAsync(defaultTenantAdmin.ToUserIdentifier());

                var jnash = await context.Users.FirstOrDefaultAsync(u => u.UserName == "jnash");
                var jnashAccount = await _userLinkManager.GetUserAccountAsync(jnash.ToUserIdentifier());

                var testTenantUser = await context.Users.FirstOrDefaultAsync(u => u.UserName == "test");
                var testTenantUserAccount = await _userLinkManager.GetUserAccountAsync(testTenantUser.ToUserIdentifier());

                jnashAccount.UserLinkId.ShouldBe(jnash.Id);
                defaultTenantAdminAccount.UserLinkId.ShouldBe(jnash.Id);
                testTenantUserAccount.UserLinkId.ShouldBe(jnash.Id);
            });
        }