skoruba / Duende.IdentityServer.Admin

The administration for the Duende IdentityServer and Asp.Net Core Identity ⚡
Apache License 2.0
556 stars 194 forks source link

Can't update client because "Client Id _clientId_ already exists" #227

Open pavvlik777 opened 1 month ago

pavvlik777 commented 1 month ago

Describe the bug

When clicking 'Save Client' button client is not updated and 'Client Id clientId already exists' error received

To Reproduce

  1. Click 'Edit' any existing client
  2. Click 'Save Client'

    Result

    Error received image

    Expected result

    Client is successfully updated

Notes

It appears that issue is caused by missing <input type="hidden" asp-for="Id" /> tag on client configuration page. Because of that model.Id is 0 on POST request and backend trying to create client rather than update existing. Issue wasn't happening on 1.1.0 version, because there was tag on basics tab.

skoruba commented 1 month ago

Hi @pavvlik777 - thanks for reporting your issue, I will check it!

skoruba commented 1 month ago

I have checked it and it works correctly for me. Id is not stored in hidden field but it is correctly populated from URL. Are you sure that you do not have some client twice? Thanks.

pavvlik777 commented 1 month ago

Hi, thanks for response.

I double-checked client id and didn't find any duplicates in db. image I was able to reproduce same issue by creating new client and clicking 'save client' immediately after that. I was redirected to creation page and id disappeared from URL. image

Also I noticed that adding clientId manually to form URL like this image fixes issue.

skoruba commented 1 month ago

What version of Admin UI do you use?

pavvlik777 commented 1 month ago

2.3.0

skoruba commented 1 month ago

Let me check it again.

Adding of <input type="hidden" asp-for="Id" /> resolved this issue?

pavvlik777 commented 1 month ago

Yes

skoruba commented 1 month ago

OK, I will merge your PR and release it in release 2.4.0. Thank you.

skoruba commented 1 month ago

Can you also check console in your browser in case that you have some JS errors?

pavvlik777 commented 1 month ago

No js errors image

skoruba commented 1 month ago

Why do you have ?area=AdminUI in your links?

pavvlik777 commented 1 month ago

Looks like it's added automatically on all links, but there were no specific adjustments to achieve this from my side. image

skoruba commented 1 month ago

Ok, interesting, I have never seen it before. 😁