standardize permissions in api

This commit is contained in:
miloschwartz
2026-07-01 11:26:14 -04:00
parent 22dd4220fe
commit 297fd2caf3
10 changed files with 45 additions and 198 deletions
+2 -12
View File
@@ -1,12 +1,10 @@
import { db, launcherViews } from "@server/db";
import { response } from "@server/lib/response";
import { getFirstString } from "@server/lib/requestParams";
import HttpCode from "@server/types/HttpCode";
import { and, eq, isNull, or } from "drizzle-orm";
import { NextFunction, Request, Response } from "express";
import createHttpError from "http-errors";
import { launcherViewConfigSchema, type LauncherViewRecord } from "./types";
import { verifyLauncherOrgMembership } from "./launcherResourceAccess";
function mapViewRow(
row: typeof launcherViews.$inferSelect
@@ -29,14 +27,8 @@ export async function listLauncherViews(
next: NextFunction
): Promise<any> {
try {
const orgId = getFirstString(req.params.orgId);
const userId = req.user?.userId;
if (!userId) {
return next(
createHttpError(HttpCode.UNAUTHORIZED, "User not authenticated")
);
}
const orgId = req.userOrgId;
const userId = req.user!.userId;
if (!orgId) {
return next(
@@ -44,8 +36,6 @@ export async function listLauncherViews(
);
}
await verifyLauncherOrgMembership(orgId, userId);
const rows = await db
.select()
.from(launcherViews)