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.

refactor: remove password reset form from account settings

Brad Barbin8df6ff124c9b
diff --git a/apps/erp/app/modules/account/ui/useAccountSubmodules.tsx b/apps/erp/app/modules/account/ui/useAccountSubmodules.tsx
index f692e2ea92..891114fbc8 100644
--- a/apps/erp/app/modules/account/ui/useAccountSubmodules.tsx
+++ b/apps/erp/app/modules/account/ui/useAccountSubmodules.tsx
@@ -1,4 +1,3 @@
-import { BsKeyFill, BsPaletteFill } from "react-icons/bs";
import { CgProfile } from "react-icons/cg";
import type { Route } from "~/types";
import { path } from "~/utils/path";
@@ -9,16 +8,6 @@ const accountRoutes: Route[] = [
to: path.to.profile,
icon: <CgProfile />,
},
- {
- name: "Password",
- to: path.to.accountPassword,
- icon: <BsKeyFill />,
- },
- {
- name: "Theme",
- to: path.to.theme,
- icon: <BsPaletteFill />,
- },
];
export default function useAccountSubmodules() {
diff --git a/apps/erp/app/routes/x+/account+/password.tsx b/apps/erp/app/routes/x+/account+/password.tsx
deleted file mode 100644
index 4573f45da6..0000000000
--- a/apps/erp/app/routes/x+/account+/password.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- assertIsPost,
- error,
- getCarbonServiceRole,
- success,
-} from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import { flash } from "@carbon/auth/session.server";
-import { validationError, validator } from "@carbon/form";
-import type { ActionFunctionArgs } from "@vercel/remix";
-import { json, redirect } from "@vercel/remix";
-import { accountPasswordValidator } from "~/modules/account";
-import { PasswordForm } from "~/modules/account/ui/Password";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const handle: Handle = {
- breadcrumb: "Password",
- to: path.to.accountPassword,
-};
-
-export async function action({ request }: ActionFunctionArgs) {
- assertIsPost(request);
- const { email, userId } = await requirePermissions(request, {});
-
- const validation = await validator(accountPasswordValidator).validate(
- await request.formData()
- );
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- const { currentPassword, password } = validation.data;
-
- const confirmPassword = await getCarbonServiceRole().auth.signInWithPassword({
- email,
- password: currentPassword,
- });
-
- if (confirmPassword.error || !("user" in confirmPassword.data)) {
- return json(
- {},
- await flash(request, error(null, "Current password is invalid"))
- );
- }
-
- const updatePassword = await getCarbonServiceRole().auth.admin.updateUserById(
- userId,
- {
- password,
- }
- );
-
- if (updatePassword.error) {
- return json(
- {},
- await flash(
- request,
- error(updatePassword.error, "Failed to update password")
- )
- );
- }
-
- throw redirect(
- path.to.authenticatedRoot,
- await flash(request, success("Updated password"))
- );
-}
-
-export default function AccountPassword() {
- return <PasswordForm />;
-}
diff --git a/apps/erp/app/routes/x+/account+/theme.tsx b/apps/erp/app/routes/x+/account+/theme.tsx
deleted file mode 100644
index 928df90bf7..0000000000
--- a/apps/erp/app/routes/x+/account+/theme.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { assertIsPost } from "@carbon/auth";
-import { validationError, validator } from "@carbon/form";
-import { useLoaderData } from "@remix-run/react";
-import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";
-import { json } from "@vercel/remix";
-import { ThemeForm, themeValidator } from "~/modules/settings";
-import { getTheme, setTheme } from "~/services/theme.server";
-import type { Handle } from "~/utils/handle";
-import { path } from "~/utils/path";
-
-export const handle: Handle = {
- breadcrumb: "Theme",
- to: path.to.theme,
-};
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const theme = getTheme(request);
-
- return json({
- theme: theme ?? "zinc",
- });
-}
-
-export async function action({ request }: ActionFunctionArgs) {
- assertIsPost(request);
- const formData = await request.formData();
-
- const validation = await validator(themeValidator).validate(formData);
-
- if (validation.error) {
- return validationError(validation.error);
- }
-
- return json(
- {},
- {
- headers: { "Set-Cookie": setTheme(validation.data.theme) },
- }
- );
-}
-
-export default function Theme() {
- const { theme } = useLoaderData<typeof loader>();
-
- const initialValues = {
- theme,
- };
-
- return <ThemeForm theme={initialValues} />;
-}