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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
Remove password login support from login pages
Claude2ac27115586a
diff --git a/apps/erp/app/routes/_public+/login.tsx b/apps/erp/app/routes/_public+/login.tsxindex d25c943e81..92e0570a75 100644--- a/apps/erp/app/routes/_public+/login.tsx+++ b/apps/erp/app/routes/_public+/login.tsx@@ -8,30 +8,13 @@ import {carbonClient,error,magicLinkValidator,- passwordLoginValidator,RATE_LIMIT} from "@carbon/auth";-import {- sendMagicLink,- signInWithEmail,- verifyAuthSession-} from "@carbon/auth/auth.server";-import { setCompanyId } from "@carbon/auth/company.server";-import {- flash,- getAuthSession,- setAuthSession-} from "@carbon/auth/session.server";+import { sendMagicLink, verifyAuthSession } from "@carbon/auth/auth.server";+import { flash, getAuthSession } from "@carbon/auth/session.server";import { getUserByEmail } from "@carbon/auth/users.server";import { sendVerificationCode } from "@carbon/auth/verification.server";-import {- Hidden,- Input,- Password,- Submit,- ValidatedForm,- validator-} from "@carbon/form";+import { Hidden, Input, Submit, ValidatedForm, validator } from "@carbon/form";import { redis } from "@carbon/kv";import {Alert,@@ -98,72 +81,6 @@ export async function action({ request }: ActionFunctionArgs) {);}- const providers = AUTH_PROVIDERS.split(",");- const isPasswordAuth = providers.includes("password");-- if (isPasswordAuth) {- const validation = await validator(passwordLoginValidator).validate(- await request.formData()- );-- if (validation.error) {- return error(validation.error, "Invalid login");- }-- const { email, password, turnstileToken } = validation.data;-- if (- CarbonEdition === Edition.Cloud &&- CLOUDFLARE_TURNSTILE_SITE_KEY !== "1x00000000000000000000AA"- ) {- const verifyResponse = await fetch(- "https://challenges.cloudflare.com/turnstile/v0/siteverify",- {- method: "POST",- headers: {- "Content-Type": "application/x-www-form-urlencoded"- },- body: new URLSearchParams({- secret: CLOUDFLARE_TURNSTILE_SECRET_KEY ?? "",- response: turnstileToken ?? "",- remoteip: ip- })- }- );-- const verifyData = await verifyResponse.json();- if (!verifyData.success) {- return data(- error(null, "Bot verification failed. Please try again."),- await flash(- request,- error(null, "Bot verification failed. Please try again.")- )- );- }- }-- const authSession = await signInWithEmail(email, password);-- if (!authSession) {- return data(- { success: false, message: "Invalid email/password combination" },- await flash(request, error(null, "Invalid email/password combination"))- );- }-- const redirectTo = validation.data.redirectTo;- const sessionCookie = await setAuthSession(request, { authSession });- const companyIdCookie = setCompanyId(authSession.companyId);-- return redirect(redirectTo || path.to.authenticatedRoot, {- headers: [- ["Set-Cookie", sessionCookie],- ["Set-Cookie", companyIdCookie]- ]- });- }-const validation = await validator(magicLinkValidator).validate(await request.formData());@@ -241,7 +158,6 @@ export default function LoginRoute() {const { providers } = useLoaderData<typeof loader>();const hasOutlookAuth = providers.includes("azure");const hasGoogleAuth = providers.includes("google");- const hasPasswordAuth = providers.includes("password");const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;@@ -311,9 +227,7 @@ export default function LoginRoute() {/></div><div className="rounded-lg md:bg-card md:border md:border-border md:shadow-lg p-8 w-[380px]">- {!hasPasswordAuth &&- fetcher.data?.success === true &&- fetcher.data?.mode === "login" ? (+ {fetcher.data?.success === true && fetcher.data?.mode === "login" ? (<><VStack spacing={4} className="items-center justify-center"><Heading size="h3">Check your email</Heading>@@ -322,7 +236,7 @@ export default function LoginRoute() {</p></VStack></>- ) : !hasPasswordAuth && mode === "verify" ? (+ ) : mode === "verify" ? (<VStack spacing={4} className="items-center"><Heading size="h3">Verify your email</Heading><p className="text-muted-foreground tracking-tight text-sm text-center">@@ -345,82 +259,6 @@ export default function LoginRoute() {Use a different email</Button></VStack>- ) : hasPasswordAuth ? (- <ValidatedForm- fetcher={fetcher}- validator={passwordLoginValidator}- defaultValues={{ redirectTo }}- method="post"- action="/login"- >- <Hidden name="redirectTo" value={redirectTo} type="hidden" />- <Hidden name="turnstileToken" value={turnstileToken} />- <VStack spacing={2}>- {fetcher.data?.success === false && fetcher.data?.message && (- <Alert variant="destructive">- <LuCircleAlert className="w-4 h-4" />- <AlertTitle>Authentication Error</AlertTitle>- <AlertDescription>{fetcher.data?.message}</AlertDescription>- </Alert>- )}-- <Input name="email" label="" placeholder="Email Address" />- <Password name="password" label="" placeholder="Password" />-- <Submit- isDisabled={- fetcher.state !== "idle" ||- (!!CLOUDFLARE_TURNSTILE_SITE_KEY && !turnstileToken)- }- isLoading={fetcher.state === "submitting"}- size="lg"- className="w-full"- withBlocker={false}- >- Sign In- </Submit>- {!!CLOUDFLARE_TURNSTILE_SITE_KEY && (- <div className="w-full flex justify-center">- <Turnstile- siteKey={CLOUDFLARE_TURNSTILE_SITE_KEY}- onSuccess={(token) => setTurnstileToken(token)}- onError={() => setTurnstileToken("")}- onExpire={() => setTurnstileToken("")}- options={{- theme: theme === "dark" ? "dark" : "light"- }}- />- </div>- )}-- {hasGoogleAuth && (- <Button- type="button"- size="lg"- className="w-full"- onClick={onSignInWithGoogle}- isDisabled={fetcher.state !== "idle"}- variant="secondary"- leftIcon={<GoogleIcon />}- >- Sign in with Google- </Button>- )}- {hasOutlookAuth && (- <Button- type="button"- size="lg"- className="w-full"- onClick={onSignInWithAzure}- isDisabled={fetcher.state !== "idle"}- variant="secondary"- leftIcon={<OutlookIcon className="size-6" />}- >- Sign in with Outlook- </Button>- )}- </VStack>- </ValidatedForm>) : (<ValidatedFormfetcher={fetcher}@@ -500,8 +338,7 @@ export default function LoginRoute() {</div><div className="flex flex-col gap-4 text-sm text-center text-balance text-muted-foreground w-[380px]">- {!hasPasswordAuth &&- mode !== "verify" &&+ {mode !== "verify" &&fetcher.data?.success !== true &&CarbonEdition !== Edition.Enterprise && (<p>Login or create a new account</p>diff --git a/apps/mes/app/routes/_public+/login.tsx b/apps/mes/app/routes/_public+/login.tsxindex 5e9b7af84f..4d32404d8c 100644--- a/apps/mes/app/routes/_public+/login.tsx+++ b/apps/mes/app/routes/_public+/login.tsx@@ -6,29 +6,12 @@ import {carbonClient,error,magicLinkValidator,- passwordLoginValidator,RATE_LIMIT} from "@carbon/auth";-import {- sendMagicLink,- signInWithEmail,- verifyAuthSession-} from "@carbon/auth/auth.server";-import { setCompanyId } from "@carbon/auth/company.server";-import {- flash,- getAuthSession,- setAuthSession-} from "@carbon/auth/session.server";+import { sendMagicLink, verifyAuthSession } from "@carbon/auth/auth.server";+import { flash, getAuthSession } from "@carbon/auth/session.server";import { getUserByEmail } from "@carbon/auth/users.server";-import {- Hidden,- Input,- Password,- Submit,- ValidatedForm,- validator-} from "@carbon/form";+import { Hidden, Input, Submit, ValidatedForm, validator } from "@carbon/form";import { redis } from "@carbon/kv";import {Alert,@@ -93,40 +76,6 @@ export async function action({ request }: ActionFunctionArgs) {);}- const providers = AUTH_PROVIDERS.split(",");- const isPasswordAuth = providers.includes("password");-- if (isPasswordAuth) {- const validation = await validator(passwordLoginValidator).validate(- await request.formData()- );-- if (validation.error) {- return error(validation.error, "Invalid login");- }-- const { email, password } = validation.data;- const authSession = await signInWithEmail(email, password);-- if (!authSession) {- return data(- { success: false, message: "Invalid email/password combination" },- await flash(request, error(null, "Invalid email/password combination"))- );- }-- const redirectTo = validation.data.redirectTo;- const sessionCookie = await setAuthSession(request, { authSession });- const companyIdCookie = setCompanyId(authSession.companyId);-- return redirect(redirectTo || path.to.authenticatedRoot, {- headers: [- ["Set-Cookie", sessionCookie],- ["Set-Cookie", companyIdCookie]- ]- });- }-const validation = await validator(magicLinkValidator).validate(await request.formData());@@ -161,7 +110,6 @@ export default function LoginRoute() {const { providers } = useLoaderData<typeof loader>();const hasOutlookAuth = providers.includes("azure");const hasGoogleAuth = providers.includes("google");- const hasPasswordAuth = providers.includes("password");const [searchParams] = useSearchParams();const redirectTo = searchParams.get("redirectTo") ?? undefined;@@ -211,7 +159,7 @@ export default function LoginRoute() {/></div><div className="rounded-lg md:bg-card md:border md:border-border md:shadow-lg p-8 w-[380px]">- {!hasPasswordAuth && fetcher.data?.success === true ? (+ {fetcher.data?.success === true ? (<><VStack spacing={4} className="items-center justify-center"><Heading size="h3">Check your email</Heading>@@ -220,64 +168,6 @@ export default function LoginRoute() {</p></VStack></>- ) : hasPasswordAuth ? (- <ValidatedForm- fetcher={fetcher}- validator={passwordLoginValidator}- defaultValues={{ redirectTo }}- method="post"- >- <Hidden name="redirectTo" value={redirectTo} type="hidden" />- <VStack spacing={2}>- {fetcher.data?.success === false && fetcher.data?.message && (- <Alert variant="destructive">- <LuCircleAlert className="w-4 h-4" />- <AlertTitle>Authentication Error</AlertTitle>- <AlertDescription>{fetcher.data?.message}</AlertDescription>- </Alert>- )}-- <Input name="email" label="" placeholder="Email Address" />- <Password name="password" label="" placeholder="Password" />-- <Submit- isDisabled={fetcher.state !== "idle"}- isLoading={fetcher.state === "submitting"}- size="lg"- className="w-full"- withBlocker={false}- >- Sign In- </Submit>-- {hasGoogleAuth && (- <Button- type="button"- size="lg"- className="w-full"- onClick={onSignInWithGoogle}- isDisabled={fetcher.state !== "idle"}- variant="secondary"- leftIcon={<GoogleIcon />}- >- Sign in with Google- </Button>- )}- {hasOutlookAuth && (- <Button- type="button"- size="lg"- className="w-full"- onClick={onSignInWithAzure}- isDisabled={fetcher.state !== "idle"}- variant="secondary"- leftIcon={<OutlookIcon className="size-6" />}- >- Sign in with Outlook- </Button>- )}- </VStack>- </ValidatedForm>) : (<ValidatedFormfetcher={fetcher}