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 => {
|
update: async config => {
|
||||||
return await API.put<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>(
|
return await API.put<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>(
|
||||||
{
|
{
|
||||||
url: `/api/oauth2`,
|
url: `/api/oauth2/${config._id}`,
|
||||||
body: {
|
body: {
|
||||||
...config,
|
...config,
|
||||||
},
|
},
|
||||||
|
|
|
@ -59,6 +59,11 @@ export async function edit(
|
||||||
ctx: Ctx<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>
|
ctx: Ctx<UpdateOAuth2ConfigRequest, UpdateOAuth2ConfigResponse>
|
||||||
) {
|
) {
|
||||||
const { body } = ctx.request
|
const { body } = ctx.request
|
||||||
|
|
||||||
|
if (ctx.params.id !== body._id) {
|
||||||
|
ctx.throw("Path and body ids do not match", 400)
|
||||||
|
}
|
||||||
|
|
||||||
const toUpdate = {
|
const toUpdate = {
|
||||||
_id: body._id,
|
_id: body._id,
|
||||||
_rev: body._rev,
|
_rev: body._rev,
|
||||||
|
|
|
@ -48,7 +48,7 @@ router.post(
|
||||||
controller.create
|
controller.create
|
||||||
)
|
)
|
||||||
router.put(
|
router.put(
|
||||||
"/api/oauth2",
|
"/api/oauth2/:id",
|
||||||
authorized(PermissionType.BUILDER),
|
authorized(PermissionType.BUILDER),
|
||||||
oAuth2ConfigValidator(updateSchema),
|
oAuth2ConfigValidator(updateSchema),
|
||||||
controller.edit
|
controller.edit
|
||||||
|
|
|
@ -31,10 +31,13 @@ export class OAuth2API extends TestAPI {
|
||||||
body: UpdateOAuth2ConfigRequest,
|
body: UpdateOAuth2ConfigRequest,
|
||||||
expectations?: Expectations
|
expectations?: Expectations
|
||||||
) => {
|
) => {
|
||||||
return await this._put<UpdateOAuth2ConfigResponse>(`/api/oauth2`, {
|
return await this._put<UpdateOAuth2ConfigResponse>(
|
||||||
body,
|
`/api/oauth2/${body._id}`,
|
||||||
expectations,
|
{
|
||||||
})
|
body,
|
||||||
|
expectations,
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete = async (id: string, rev: string, expectations?: Expectations) => {
|
delete = async (id: string, rev: string, expectations?: Expectations) => {
|
||||||
|
|
Loading…
Reference in New Issue