Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: fallback if we can't find the user from slack

Brad Barbin3a2c4b1616b6
diff --git a/apps/erp/app/routes/_public+/login.tsx b/apps/erp/app/routes/_public+/login.tsx
index b021243d8a..f3cd361ce2 100644
--- a/apps/erp/app/routes/_public+/login.tsx
+++ b/apps/erp/app/routes/_public+/login.tsx
@@ -59,7 +59,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const ratelimit = new Ratelimit({
redis,
- limiter: Ratelimit.slidingWindow(15, "1 h"),
+ limiter: Ratelimit.slidingWindow(5, "1 h"),
analytics: true,
});
diff --git a/apps/erp/app/routes/_public+/verify.tsx b/apps/erp/app/routes/_public+/verify.tsx
index e52c6bb0d0..acc392715e 100644
--- a/apps/erp/app/routes/_public+/verify.tsx
+++ b/apps/erp/app/routes/_public+/verify.tsx
@@ -59,7 +59,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
const ratelimit = new Ratelimit({
redis,
- limiter: Ratelimit.slidingWindow(15, "1 h"), // 5 submissions per hour
+ limiter: Ratelimit.slidingWindow(5, "1 h"), // 5 submissions per hour
analytics: true,
});
diff --git a/packages/integrations/src/slack/lib/service.ts b/packages/integrations/src/slack/lib/service.ts
index c34f0684dd..6a35750e7e 100644
--- a/packages/integrations/src/slack/lib/service.ts
+++ b/packages/integrations/src/slack/lib/service.ts
@@ -315,8 +315,19 @@ export async function getCarbonEmployeeFromSlackId(
.select("id")
.eq("email", email)
.single();
- if (user.error) {
- throw new Error("User not found");
+ if (user.error || !user.data?.id) {
+ const location = await client
+ .from("location")
+ .select("id")
+ .eq("companyId", carbonCompanyId)
+ .single();
+ return {
+ data: {
+ id: "system",
+ locationId: location.data?.id,
+ },
+ error: null,
+ };
}
return client
.from("employeeJob")