Add an error if trying to add new users to the user metadata table within an app - this is invalid and should throw an error.
This commit is contained in:
parent
f15ca351cd
commit
ff5e9a468d
|
@ -72,6 +72,11 @@ export const save = async (ctx: UserCtx<Row, Row>) => {
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
const body = ctx.request.body
|
const body = ctx.request.body
|
||||||
|
|
||||||
|
// user metadata doesn't exist yet - don't allow creation
|
||||||
|
if (utils.isUserMetadataTable(tableId) && !body._rev) {
|
||||||
|
ctx.throw(400, "Cannot create new user entry.")
|
||||||
|
}
|
||||||
|
|
||||||
// if it has an ID already then its a patch
|
// if it has an ID already then its a patch
|
||||||
if (body && body._id) {
|
if (body && body._id) {
|
||||||
return patch(ctx as UserCtx<PatchRowRequest, PatchRowResponse>)
|
return patch(ctx as UserCtx<PatchRowRequest, PatchRowResponse>)
|
||||||
|
|
|
@ -175,3 +175,7 @@ export function removeEmptyFilters(filters: SearchFilters) {
|
||||||
}
|
}
|
||||||
return filters
|
return filters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isUserMetadataTable(tableId: string) {
|
||||||
|
return tableId === InternalTables.USER_METADATA
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue