public async Task <ClientDto> UpdateAsync(Guid id, UpdateClientInputDto input) { var clientIdIsExist = await _repository.CheckClientIdExistAsync(input.ClientId, id); if (clientIdIsExist) { throw new ClientIdNotAllowedDuplicateException(input.ClientId); } // 新生成密钥为明文,需要sha256 input.TryEncryptSecrets(); var client = await _repository.FindAsync(id, true); client = ObjectMapper.Map <UpdateClientInputDto, Client>(input, client); client.RemoveAllIdentityProviderRestrictions(); input.IdentityProviderRestrictions .ForEach(x => client.AddIdentityProviderRestriction(x)); client.RemoveAllPostLogoutRedirectUris(); input.PostLogoutRedirectUris .ForEach(x => client.AddPostLogoutRedirectUri(x)); client.RemoveAllRedirectUris(); input.RedirectUris .ForEach(x => client.AddRedirectUri(x)); client.RemoveAllCorsOrigins(); input.AllowedCorsOrigins .ForEach(x => client.AddCorsOrigin(x)); client.RemoveAllAllowedGrantTypes(); input.AllowedGrantTypes .ForEach(x => client.AddGrantType(x)); client.RemoveAllScopes(); input.AllowedScopes .ForEach(x => client.AddScope(x)); client.RemoveAllProperties(); input.Properties .ForEach(x => client.AddProperty(x.Key, x.Value)); client = await _repository.UpdateAsync(client); return(MapToGetOutputDto(client)); }
public async Task <ClientDto> UpdateAsync(Guid id, UpdateClientInputDto input) { return(await this._clientAppService.UpdateAsync(id, input)); }