Пример #1
0
        public Task RemoveLoginAsync(TUser user, UserLoginInfo login)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (login == null)
            {
                throw new ArgumentNullException("login");
            }
            var tUserLogin = user.Logins.SingleOrDefault(l =>
            {
                if (l.LoginProvider != login.LoginProvider)
                {
                    return(false);
                }
                return(l.ProviderKey == login.ProviderKey);
            });

            if (tUserLogin != null)
            {
                user.Logins.Remove(tUserLogin);

                _userLoginRepository.Delete(user, login);
            }
            return(Task.FromResult <int>(0));
        }
Пример #2
0
        public Task RemoveLoginAsync(TUser user, UserLoginInfo login)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (login == null)
            {
                throw new ArgumentNullException("login");
            }

            UserLoginRepository.Delete(new IdentityUserLogin {
                LoginProvider = login.LoginProvider, ProviderKey = login.ProviderKey, UserId = user.Id
            });

            return(Task.FromResult <Object>(null));
        }
Пример #3
0
 /// <summary>
 /// 删除用户登录信息
 /// </summary>
 /// <param name="ids">要删除的登录信息</param>
 /// <param name="cache">当前操作的缓存用户</param>
 /// <returns>业务操作结果</returns>
 public async Task <OperationResult> DeleteUserLogin(CacheUser cache, params Guid[] ids)
 {
     try
     {
         OperationResult result = UserLoginRepository.Delete(ids,
                                                             checkAction: entity => {
             if (cache.IsAdministrator)
             {
                 return;
             }
             if (!cache.Level.IsBetween(1, 2))
             {
                 throw new Exception($"id:你没有权限进行该功能操作!");
             }
             var listId = from a in UserOrganizeMapRepository.Entities
                          join b in UserLoginRepository.Entities on
                          a.Organize_Id equals b.Organize_Id
                          where a.UserLogin_Id == cache.Id
                          select b.Id;
             foreach (var i in ids)
             {
                 if (!listId.Contains(i))
                 {
                     throw new Exception($"id:主键:{i}的用户信息不存在你的操作范围!,");
                 }
             }
         },
                                                             deleteFunc: entity =>
         {
             if (entity == null)
             {
                 throw new Exception("id:准备删除的目标不存在");
             }
             HostPolicyLogRepository.Delete(m => m.UserLogin_Id == entity.Id);
             return(entity);
         });
         return(await Task.FromResult(result));
     }
     catch (Exception ex)
     {
         throw new Exception($"id:{ex.InnerException.Message}");
     }
 }