Re-add id on the edit path
This commit is contained in:
parent
64b32bc33d
commit
2ac2fb5a9b
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -48,7 +48,7 @@ router.post(
|
|||
controller.create
|
||||
)
|
||||
router.put(
|
||||
"/api/oauth2",
|
||||
"/api/oauth2/:id",
|
||||
authorized(PermissionType.BUILDER),
|
||||
oAuth2ConfigValidator(updateSchema),
|
||||
controller.edit
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue