public async Task Delete(int id) { if (!await CanManage(id)) { throw new InvalidOperationException(); } await _store.Delete(id); }
private async Task ImportClient(ClientImport client, Data.Resource[] resources) { string guid = Guid.NewGuid().ToString(); var clients = await _clients.List().ToArrayAsync(); var entity = clients.Where(c => c.Name == client.Id).SingleOrDefault(); if (entity != null) { guid = entity.GlobalId; await _clients.Delete(entity.Id); } entity = new Data.Client { Name = client.Id, GlobalId = guid, Enabled = true, DisplayName = client.DisplayName ?? client.Id, Grants = client.GrantType, Scopes = client.Scopes, Flags = ClientFlag.Published | ClientFlag.EnableLocalLogin | ClientFlag.AllowOfflineAccess | ClientFlag.AllowRememberConsent }; if ("implicit hybrid".Contains(client.GrantType)) { entity.Flags |= ClientFlag.AllowAccessTokensViaBrowser; } if (client.RedirectUrl.HasValue()) { entity.Urls = new Data.ClientUri[] { new Data.ClientUri { Type = ClientUriType.RedirectUri, Value = client.RedirectUrl } }; } if (client.Secret.HasValue()) { entity.Secrets.Add( new Data.ClientSecret { Type = "SharedSecret", Value = client.Secret.Sha256(), Description = "Added by Admin at " + DateTime.UtcNow.ToString("u") } ); } await _clients.Add(entity); }
public async Task DeleteClient(Client client) { await _clientStore.Delete(client); }