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(auth): magic link 500 without redirect_to; move Open in MES into job menu (#2022)

Brad Barbin6580fa238a1a
diff --git a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
index 55a4f26be2..23a2218212 100644
--- a/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
+++ b/apps/erp/app/modules/production/ui/Jobs/JobHeader.tsx
@@ -232,6 +232,18 @@ const JobHeader = () => {
const menuItems = (
<>
{auditLogTrigger}
+ {["Ready", "In Progress", "Paused"].includes(status ?? "") && (
+ <DropdownMenuItem asChild>
+ <a
+ href={path.to.external.mesJob(jobId)}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <DropdownMenuIcon icon={<LuTvMinimalPlay />} />
+ <Trans>Open in MES</Trans>
+ </a>
+ </DropdownMenuItem>
+ )}
<DropdownMenuSeparator />
<DropdownMenuItem
disabled={
@@ -373,23 +385,6 @@ const JobHeader = () => {
</Button>
</RecordAction>
)}
- {["Ready", "In Progress", "Paused"].includes(status ?? "") && (
- <RecordAction slot="overflow">
- <Button
- leftIcon={<LuTvMinimalPlay />}
- variant="secondary"
- asChild
- >
- <a
- href={path.to.external.mesJob(jobId)}
- target="_blank"
- rel="noopener noreferrer"
- >
- <Trans>Open in MES</Trans>
- </a>
- </Button>
- </RecordAction>
- )}
<RecordAction slot="overflow">
<DropdownMenu>
<DropdownMenuTrigger asChild>
diff --git a/apps/erp/app/routes/_public+/magic-link.tsx b/apps/erp/app/routes/_public+/magic-link.tsx
index cb69245099..c896237e1f 100644
--- a/apps/erp/app/routes/_public+/magic-link.tsx
+++ b/apps/erp/app/routes/_public+/magic-link.tsx
@@ -42,18 +42,19 @@ export default function ConfirmMagicLink() {
// The app that asked for the email: the link carries Auth's RedirectTo,
// its /callback. Anything else (Auth's bare Site URL when it refused the
// app's address, an older email without it) finishes here instead. Auth's
- // /verify redirects only to its allow list either way.
- const redirectTo = (() => {
+ // /verify redirects only to its allow list either way. Read on click only:
+ // this page server-renders, and `window` does not exist there.
+ const getRedirectTo = () => {
const asked = params.get("redirect_to");
try {
if (asked && new URL(asked).pathname === "/callback") return asked;
} catch {
// not a URL
}
- return `${window?.location.origin}/callback`;
- })();
+ return `${window.location.origin}/callback`;
+ };
const getConfirmationURL = (token: string) => {
- return `${SUPABASE_URL}/auth/v1/verify?token=${token}&type=magiclink&redirect_to=${encodeURIComponent(redirectTo)}`;
+ return `${SUPABASE_URL}/auth/v1/verify?token=${token}&type=magiclink&redirect_to=${encodeURIComponent(getRedirectTo())}`;
};
return (