1
0
mirror of https://git.teknik.io/Teknikode/Teknik.git synced 2023-08-02 14:16:22 +02:00

- Fixed client key not being displayed after creation.

- Fixed clients not being able to be deleted.
This commit is contained in:
Uncled1023 2019-01-17 22:24:31 -08:00
parent 2c07ba868f
commit 96100ec2cd
2 changed files with 12 additions and 6 deletions

View File

@ -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<IActionResult> 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 });

View File

@ -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: '<label for="clientSecret">Make sure to copy your client secret now.<br />You won\'t be able to see it again!</label><input type="text" class="form-control" id="clientSecret" value="' + response.result.secret + '">',
message: '<label for="clientSecret">Make sure to copy your client secret now.<br />You won\'t be able to see it again!</label><input type="text" class="form-control" id="clientSecret" value="' + response.secret + '">',
});
dialog.init(function () {