massive refactor toDrop cascadeStudio and add CadQuery + OpenSCAD

resolves #400
This commit is contained in:
Kurt Hutten
2021-07-08 21:17:07 +10:00
parent 477a557eb8
commit 8e558d2342
158 changed files with 2335 additions and 2300 deletions

View File

@@ -1,13 +1,17 @@
import { AuthenticationError, ForbiddenError } from '@redwoodjs/api'
import { db } from 'src/lib/db'
export const requireOwnership = async ({ userId, userName, partId } = {}) => {
export const requireOwnership = async ({
userId,
userName,
projectId,
}: { userId?: string; userName?: string; projectId?: string } = {}) => {
// IMPORTANT, don't forget to await this function, as it will only block
// unwanted db actions if it has time to look up resources in the db.
if (!context.currentUser) {
throw new AuthenticationError("You don't have permission to do that.")
}
if (!userId && !userName && !partId) {
if (!userId && !userName && !projectId) {
throw new ForbiddenError("You don't have access to do that.")
}
@@ -33,10 +37,10 @@ export const requireOwnership = async ({ userId, userName, partId } = {}) => {
}
}
if (partId) {
const user = await db.part
if (projectId) {
const user = await db.project
.findUnique({
where: { id: partId },
where: { id: projectId },
})
.user()