コード例 #1
0
        public async Task UnlinkUser(UnlinkUserInput input)
        {
            var currentUserAccount = await _userLinkManager.GetUserAccountAsync(AbpSession.ToUserIdentifier());

            if (!currentUserAccount.UserLinkId.HasValue)
            {
                throw new ApplicationException(L("You are not linked to any account"));
            }

            if (!await _userLinkManager.AreUsersLinked(AbpSession.ToUserIdentifier(), input.ToUserIdentifier()))
            {
                return;
            }

            await _userLinkManager.Unlink(input.ToUserIdentifier());
        }
コード例 #2
0
        public async Task UnlinkUser(UnlinkUserInput input)
        {
            var currentUserId = AbpSession.GetUserId();
            var currentUser   = await UserManager.GetUserByIdAsync(currentUserId);

            if (!currentUser.UserLinkId.HasValue)
            {
                throw new ApplicationException(L("You are not linked to any account"));
            }

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
            {
                if (!await _userLinkManager.AreUsersLinked(currentUserId, input.UserId))
                {
                    return;
                }

                await _userLinkManager.Unlink(input.UserId);
            }
        }
コード例 #3
0
        public virtual async Task <JsonResult> SwitchToLinkedAccount(SwitchToLinkedAccountModel model)
        {
            CheckModelState();

            using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant))
            {
                if (!await _userLinkManager.AreUsersLinked(AbpSession.GetUserId(), model.TargetUserId))
                {
                    throw new ApplicationException(L("This account is not linked to your account"));
                }

                var targetUser = await _userManager.FindByIdAsync(model.TargetUserId);

                var targetTenantId = targetUser.TenantId;

                var result = await SaveAccountSwitchTokenAndGetTargetUrl(targetTenantId, model.TargetUserId);

                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                return(result);
            }
        }