Browse Source

- Fixed client key not being displayed after creation.

- Fixed clients not being able to be deleted.
tags/3.0.0^2
Teknikode 10 months ago
parent
commit
96100ec2cd

+ 10
- 4
IdentityServer/Controllers/ManageController.cs 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 });

+ 2
- 2
Teknik/Scripts/User/DeveloperSettings.js 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 () {

Loading…
Cancel
Save