diff --git a/IdentityServer/Controllers/ManageController.cs b/IdentityServer/Controllers/ManageController.cs index 9488520..8349c99 100644 --- a/IdentityServer/Controllers/ManageController.cs +++ b/IdentityServer/Controllers/ManageController.cs @@ -456,7 +456,13 @@ namespace Teknik.IdentityServer.Controllers [HttpPost] public IActionResult CreateClient(CreateClientModel model, [FromServices] ConfigurationDbContext configContext) { + // Generate a unique client ID var clientId = StringHelper.RandomString(20, "abcdefghjkmnpqrstuvwxyz1234567890"); + while (configContext.Clients.Where(c => c.ClientId == clientId).FirstOrDefault() != null) + { + clientId = StringHelper.RandomString(20, "abcdefghjkmnpqrstuvwxyz1234567890"); + } + var clientSecret = StringHelper.RandomString(40, "abcdefghjkmnpqrstuvwxyz1234567890"); var client = new IdentityServer4.Models.Client @@ -502,12 +508,12 @@ namespace Teknik.IdentityServer.Controllers } [HttpPost] - public async Task DeleteClient(DeleteClientModel model, [FromServices] IClientStore clientStore, [FromServices] ConfigurationDbContext configContext) - { - var foundClient = await clientStore.FindClientByIdAsync(model.ClientId); + public IActionResult DeleteClient(DeleteClientModel model, [FromServices] ConfigurationDbContext configContext) + { + var foundClient = configContext.Clients.Where(c => c.ClientId == model.ClientId).FirstOrDefault(); if (foundClient != null) { - configContext.Clients.Remove(foundClient.ToEntity()); + configContext.Clients.Remove(foundClient); configContext.SaveChanges(); return new JsonResult(new { success = true }); diff --git a/Teknik/Scripts/User/DeveloperSettings.js b/Teknik/Scripts/User/DeveloperSettings.js index 8849f05..7bb2cdd 100644 --- a/Teknik/Scripts/User/DeveloperSettings.js +++ b/Teknik/Scripts/User/DeveloperSettings.js @@ -27,7 +27,7 @@ if ($('#noClients')) { $('#noClients').remove(); } - var item = $(response.result.html); + var item = $(response.html); var deleteBtn = item.find('.deleteClient'); @@ -41,7 +41,7 @@ } }, title: "Client Secret", - message: '', + message: '', }); dialog.init(function () {