Add support for child users adding limits themself

This commit is contained in:
Jonas Lochmann
2020-08-03 02:00:00 +02:00
parent a73af1338e
commit 007b1f2ec9
11 changed files with 375 additions and 99 deletions
@@ -19,10 +19,17 @@ import { CreateCategoryAction } from '../../../../action'
import { generateVersionId } from '../../../../util/token'
import { Cache } from '../cache'
export async function dispatchCreateCategory ({ action, cache }: {
export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimitAddChildUserId }: {
action: CreateCategoryAction
cache: Cache
fromChildSelfLimitAddChildUserId: string | null
}) {
if (fromChildSelfLimitAddChildUserId !== null) {
if (fromChildSelfLimitAddChildUserId !== action.childId) {
throw new Error('can not create categories for other child users')
}
}
// check that the child exists
const childEntry = await cache.database.user.findOne({
where: {