Re-add id on the edit path

This commit is contained in:
Adria Navarro 2025-03-21 09:07:57 +01:00
parent 64b32bc33d
commit 2ac2fb5a9b
4 changed files with 14 additions and 6 deletions

View File

@ -55,7 +55,7 @@ export const buildOAuth2Endpoints = (API: BaseAPIClient): OAuth2Endpoints => ({
update: async config => {
return await API.put<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>(
{
url: `/api/oauth2`,
url: `/api/oauth2/${config._id}`,
body: {
...config,
},

View File

@ -59,6 +59,11 @@ export async function edit(
ctx: Ctx<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>
) {
const { body } = ctx.request
if (ctx.params.id !== body._id) {
ctx.throw("Path and body ids do not match", 400)
}
const toUpdate = {
_id: body._id,
_rev: body._rev,

View File

@ -48,7 +48,7 @@ router.post(
controller.create
)
router.put(
"/api/oauth2",
"/api/oauth2/:id",
authorized(PermissionType.BUILDER),
oAuth2ConfigValidator(updateSchema),
controller.edit

View File

@ -31,10 +31,13 @@ export class OAuth2API extends TestAPI {
body: UpdateOAuth2ConfigRequest,
expectations?: Expectations
) => {
return await this._put<UpdateOAuth2ConfigResponse>(`/api/oauth2`, {
body,
expectations,
})
return await this._put<UpdateOAuth2ConfigResponse>(
`/api/oauth2/${body._id}`,
{
body,
expectations,
}
)
}
delete = async (id: string, rev: string, expectations?: Expectations) => {