1
0
Fork 0
mirror of synced 2024-08-09 15:17:57 +12:00

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:
mike12345567 2023-09-14 12:44:14 +01:00
parent f15ca351cd
commit ff5e9a468d
2 changed files with 9 additions and 0 deletions

View file

@ -72,6 +72,11 @@ export const save = async (ctx: UserCtx<Row, Row>) => {
const tableId = utils.getTableId(ctx)
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 (body && body._id) {
return patch(ctx as UserCtx<PatchRowRequest, PatchRowResponse>)

View file

@ -175,3 +175,7 @@ export function removeEmptyFilters(filters: SearchFilters) {
}
return filters
}
export function isUserMetadataTable(tableId: string) {
return tableId === InternalTables.USER_METADATA
}