fix bug preventing creating raw resources with api key closes #920

This commit is contained in:
miloschwartz 2025-06-18 16:42:07 -04:00
parent b56ba3ee23
commit c043912f94
No known key found for this signature in database

View file

@ -39,7 +39,7 @@ const createHttpResourceSchema = z
isBaseDomain: z.boolean().optional(), isBaseDomain: z.boolean().optional(),
siteId: z.number(), siteId: z.number(),
http: z.boolean(), http: z.boolean(),
protocol: z.string(), protocol: z.enum(["tcp", "udp"]),
domainId: z.string() domainId: z.string()
}) })
.strict() .strict()
@ -71,7 +71,7 @@ const createRawResourceSchema = z
name: z.string().min(1).max(255), name: z.string().min(1).max(255),
siteId: z.number(), siteId: z.number(),
http: z.boolean(), http: z.boolean(),
protocol: z.string(), protocol: z.enum(["tcp", "udp"]),
proxyPort: z.number().int().min(1).max(65535) proxyPort: z.number().int().min(1).max(65535)
}) })
.strict() .strict()
@ -85,7 +85,7 @@ const createRawResourceSchema = z
return true; return true;
}, },
{ {
message: "Proxy port cannot be set" message: "Raw resources are not allowed"
} }
); );
@ -392,7 +392,7 @@ async function createRawResource(
resourceId: newResource[0].resourceId resourceId: newResource[0].resourceId
}); });
if (req.userOrgRoleId != adminRole[0].roleId) { if (req.user && req.userOrgRoleId != adminRole[0].roleId) {
// make sure the user can access the resource // make sure the user can access the resource
await trx.insert(userResources).values({ await trx.insert(userResources).values({
userId: req.user?.userId!, userId: req.user?.userId!,