public async Task UnBind(Guid id) { LinUserIdentity userIdentity = await _userIdentityRepository.GetAsync(id); if (userIdentity == null || userIdentity.CreateUserId != CurrentUser.Id) { throw new LinCmsException("你无权解绑此账号"); } List <LinUserIdentity> userIdentities = await _userIdentityRepository.Select.Where(r => r.CreateUserId == CurrentUser.Id).ToListAsync(); bool hasPwd = userIdentities.Where(r => r.IdentityType == LinUserIdentity.Password).Any(); if (!hasPwd && userIdentities.Count == 1) { throw new LinCmsException("你未设置密码,无法解绑最后一个第三方登录账号"); } await _userIdentityRepository.DeleteAsync(userIdentity); }