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: add link that can be opened by spam detection for invite/magic link flow

Brad Barbinc8bb008bd692
diff --git a/apps/carbon/app/routes/_public+/_layout.tsx b/apps/carbon/app/routes/_public+/_layout.tsx
index e2f9dbaf8a..3a68364870 100644
--- a/apps/carbon/app/routes/_public+/_layout.tsx
+++ b/apps/carbon/app/routes/_public+/_layout.tsx
@@ -7,7 +7,7 @@ export default function PublicRoute() {
<div className="flex min-h-screen min-w-screen">
<VStack
spacing={8}
- className="items-center justify-start pt-[20vh] mx-auto max-w-lg z-[3]"
+ className="items-center justify-start pt-[20dvh] mx-auto max-w-lg z-[3]"
>
<Outlet />
</VStack>
diff --git a/apps/carbon/app/routes/_public+/confirm-invite.tsx b/apps/carbon/app/routes/_public+/confirm-invite.tsx
new file mode 100644
index 0000000000..55532e8e5e
--- /dev/null
+++ b/apps/carbon/app/routes/_public+/confirm-invite.tsx
@@ -0,0 +1,72 @@
+import { Button as _Button, Heading as _Heading, VStack } from "@carbon/react";
+import { useNavigate, useSearchParams } from "@remix-run/react";
+import { AnimatePresence, motion } from "framer-motion";
+
+const Heading = motion(_Heading);
+const Button = motion(_Button);
+
+const fade = {
+ initial: { opacity: 0 },
+ animate: { opacity: 1 },
+};
+
+export default function ConfirmInvite() {
+ const [params] = useSearchParams();
+ const navigate = useNavigate();
+
+ const redirectTo = params.get("redirect");
+ if (!redirectTo) {
+ navigate("/");
+ return null;
+ }
+
+ return (
+ <AnimatePresence>
+ <VStack
+ spacing={4}
+ className="max-w-lg pt-[20dvh] items-center text-center"
+ >
+ <motion.img
+ initial={{ opacity: 0, scale: 0.4 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 2, ease: "easeInOut" }}
+ src="/carbon-logo-dark.png"
+ alt="Carbon Logo"
+ className="block dark:hidden max-w-[60px] mb-3"
+ />
+ <motion.img
+ initial={{ opacity: 0, scale: 0.4 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 2, ease: "easeInOut" }}
+ src="/carbon-logo-light.png"
+ alt="Carbon Logo"
+ className="hidden dark:block max-w-[60px] mb-3"
+ />
+ <Heading
+ {...fade}
+ transition={{ duration: 1.2, ease: "easeInOut", delay: 1.5 }}
+ size="h1"
+ className="m-0"
+ >
+ Welcome to CarbonOS
+ </Heading>
+ <motion.p
+ {...fade}
+ transition={{ duration: 1.4, ease: "easeInOut", delay: 1.9 }}
+ className="text-muted-foreground text-sm pb-4"
+ >
+ CarbonOS is the operating system for manufacturing
+ </motion.p>
+
+ <Button
+ {...fade}
+ transition={{ duration: 1, delay: 2.4 }}
+ size="lg"
+ asChild
+ >
+ <a href={redirectTo}>Accept Invite</a>
+ </Button>
+ </VStack>
+ </AnimatePresence>
+ );
+}
diff --git a/apps/carbon/app/routes/_public+/confirm-magic-link.tsx b/apps/carbon/app/routes/_public+/confirm-magic-link.tsx
new file mode 100644
index 0000000000..73b7f13187
--- /dev/null
+++ b/apps/carbon/app/routes/_public+/confirm-magic-link.tsx
@@ -0,0 +1,72 @@
+import { Button as _Button, Heading as _Heading, VStack } from "@carbon/react";
+import { useNavigate, useSearchParams } from "@remix-run/react";
+import { AnimatePresence, motion } from "framer-motion";
+
+const Heading = motion(_Heading);
+const Button = motion(_Button);
+
+const fade = {
+ initial: { opacity: 0 },
+ animate: { opacity: 1 },
+};
+
+export default function ConfirmInvite() {
+ const [params] = useSearchParams();
+ const navigate = useNavigate();
+
+ const redirectTo = params.get("redirect");
+ if (!redirectTo) {
+ navigate("/");
+ return null;
+ }
+
+ return (
+ <AnimatePresence>
+ <VStack
+ spacing={4}
+ className="max-w-lg pt-[20dvh] items-center text-center"
+ >
+ <motion.img
+ initial={{ opacity: 0, scale: 0.4 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 2, ease: "easeInOut" }}
+ src="/carbon-logo-dark.png"
+ alt="Carbon Logo"
+ className="block dark:hidden max-w-[60px] mb-3"
+ />
+ <motion.img
+ initial={{ opacity: 0, scale: 0.4 }}
+ animate={{ opacity: 1, scale: 1 }}
+ transition={{ duration: 2, ease: "easeInOut" }}
+ src="/carbon-logo-light.png"
+ alt="Carbon Logo"
+ className="hidden dark:block max-w-[60px] mb-3"
+ />
+ <Heading
+ {...fade}
+ transition={{ duration: 1.2, ease: "easeInOut", delay: 1.5 }}
+ size="h1"
+ className="m-0"
+ >
+ Welcome to CarbonOS
+ </Heading>
+ <motion.p
+ {...fade}
+ transition={{ duration: 1.4, ease: "easeInOut", delay: 1.9 }}
+ className="text-muted-foreground text-sm pb-4"
+ >
+ CarbonOS is the operating system for manufacturing
+ </motion.p>
+
+ <Button
+ {...fade}
+ transition={{ duration: 1, delay: 2.4 }}
+ size="lg"
+ asChild
+ >
+ <a href={redirectTo}>Log In</a>
+ </Button>
+ </VStack>
+ </AnimatePresence>
+ );
+}
diff --git a/packages/auth/src/services/auth.server.ts b/packages/auth/src/services/auth.server.ts
index 4e942b2139..191803117e 100644
--- a/packages/auth/src/services/auth.server.ts
+++ b/packages/auth/src/services/auth.server.ts
@@ -161,7 +161,7 @@ export async function sendInviteByEmail(
data?: Record<string, unknown>
) {
return getCarbonServiceRole().auth.admin.inviteUserByEmail(email, {
- redirectTo: `${VERCEL_URL}/callback`,
+ redirectTo: `${VERCEL_URL}`,
data,
});
}
@@ -170,7 +170,7 @@ export async function sendMagicLink(email: string) {
return getCarbonServiceRole().auth.signInWithOtp({
email,
options: {
- emailRedirectTo: `${VERCEL_URL}/callback`,
+ emailRedirectTo: `${VERCEL_URL}`,
},
});
}
diff --git a/packages/database/supabase/config.toml b/packages/database/supabase/config.toml
index d1d84e77b1..6f526c73de 100644
--- a/packages/database/supabase/config.toml
+++ b/packages/database/supabase/config.toml
@@ -89,10 +89,13 @@ double_confirm_changes = true
# If enabled, users need to confirm their email address before signing in.
enable_confirmations = false
-# Uncomment to customize email template
-# [auth.email.template.invite]
-# subject = "You have been invited"
-# content_path = "./supabase/templates/invite.html"
+[auth.email.template.invite]
+subject = "You have been invited to CarbonOS"
+content_path = "./supabase/templates/invite.html"
+
+[auth.email.template.magic_link]
+subject = "Your CarbonOS Magic Link"
+content_path = "./supabase/templates/magic-link.html"
[auth.sms]
# Allow/disallow new user signups via SMS to your project.
diff --git a/packages/database/supabase/templates/invite.html b/packages/database/supabase/templates/invite.html
new file mode 100644
index 0000000000..3adde865e1
--- /dev/null
+++ b/packages/database/supabase/templates/invite.html
@@ -0,0 +1,12 @@
+<h2>You have been invited to CarbonOS</h2>
+
+<p>
+ You have been invited to create a user on CarbonOS. Follow this link to accept
+ the invite:
+</p>
+<p>
+ <a
+ href="{{ .SiteURL }}/confirm-invite?redirect={{ .ConfirmationURL }}/callback"
+ >Accept the invite</a
+ >
+</p>
diff --git a/packages/database/supabase/templates/magic-link.html b/packages/database/supabase/templates/magic-link.html
new file mode 100644
index 0000000000..28ff99e489
--- /dev/null
+++ b/packages/database/supabase/templates/magic-link.html
@@ -0,0 +1,8 @@
+<h2>Magic Link for CarbonOS</h2>
+
+<p>Follow this link to login:</p>
+<p>
+ <a href="{{ .SiteURL }}/confirm-magic-link?redirect={{ .ConfirmationURL }}"
+ >Log In</a
+ >
+</p>
diff --git a/packages/react/src/Alert.tsx b/packages/react/src/Alert.tsx
index cfc4256923..f890e22561 100644
--- a/packages/react/src/Alert.tsx
+++ b/packages/react/src/Alert.tsx
@@ -11,11 +11,11 @@ const alertVariants = cva(
variant: {
default: "bg-background text-foreground",
success:
- "bg-gradient-to-r dark:from-emerald-600/60 dark:via-card dark:to-card from-emerald-100 to-emerald-100 border-emerald-600 text-emerald-600 [&>svg]:text-emerald-600 dark:text-foreground dark:[&>svg]:text-foreground",
+ "bg-gradient-to-r dark:from-emerald-600/30 dark:via-card dark:to-card from-emerald-100 to-emerald-100 border-emerald-600 text-emerald-600 [&>svg]:text-emerald-600 dark:text-foreground dark:[&>svg]:text-foreground",
warning:
- "bg-gradient-to-r dark:from-yellow-700/60 dark:via-card dark:to-card from-yellow-100/10 to-yellow-100/10 border-yellow-700 text-yellow-800 [&>svg]:text-yellow-800 dark:text-foreground dark:[&>svg]:text-foreground",
+ "bg-gradient-to-r dark:from-yellow-700/30 dark:via-card dark:to-card from-yellow-100/10 to-yellow-100/10 border-yellow-700 text-yellow-800 [&>svg]:text-yellow-800 dark:text-foreground dark:[&>svg]:text-foreground",
destructive:
- "bg-gradient-to-r dark:from-destructive/60 dark:via-card dark:to-card from-destructive/10 to-destructive/10 border-destructive text-destructive [&>svg]:text-destructive dark:text-foreground dark:[&>svg]:text-foreground",
+ "bg-gradient-to-r dark:from-destructive/30 dark:via-card dark:to-card from-destructive/10 to-destructive/10 border-destructive text-destructive [&>svg]:text-destructive dark:text-foreground dark:[&>svg]:text-foreground",
},
},
defaultVariants: {