diff --git a/app/(dashboard)/[tenant]/settings/actions.ts b/app/(dashboard)/[tenant]/settings/actions.ts
index 779a4a9..d7a7b43 100644
--- a/app/(dashboard)/[tenant]/settings/actions.ts
+++ b/app/(dashboard)/[tenant]/settings/actions.ts
@@ -1,7 +1,12 @@
"use server";
+import { logtoConfig } from "@/app/logto";
+import { user } from "@/drizzle/schema";
import { updateUser } from "@/lib/ops/auth";
+import { database } from "@/lib/utils/useDatabase";
import { getOwner } from "@/lib/utils/useOwner";
+import { signOut } from "@logto/next/server-actions";
+import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";
@@ -25,5 +30,19 @@ export async function updateUserData(payload: FormData) {
[key]: value,
});
revalidatePath(`/${orgSlug}/settings`);
+
+ const db = await database();
+ if (key === "name") {
+ const [firstName, lastName] = value.split(" ");
+ db.update(user)
+ .set({ firstName, lastName })
+ .where(eq(user.id, userId))
+ .run();
+ }
+
return { success: true };
}
+
+export async function logout() {
+ await signOut(logtoConfig);
+}
diff --git a/components/console/navbar-links.tsx b/components/console/navbar-links.tsx
index c249511..40d54db 100644
--- a/components/console/navbar-links.tsx
+++ b/components/console/navbar-links.tsx
@@ -11,11 +11,10 @@ import { useMemo } from "react";
import logo from "../../public/images/logo.png";
import { createToastWrapper } from "../core/toast";
-export default function NavBarLinks() {
+export default function NavBarLinks({ orgSlug }: { orgSlug: string }) {
const { systemTheme: theme } = useTheme();
const path = usePathname();
const { projectId } = useParams();
- const orgSlug = "personal";
const [isSticky, ref] = useDetectSticky();
@@ -65,7 +64,7 @@ export default function NavBarLinks() {
current: path.endsWith("/settings"),
},
];
- }, [path, projectId]);
+ }, [path, projectId, orgSlug]);
return (
<>
diff --git a/components/console/navbar.tsx b/components/console/navbar.tsx
index 9dbd579..9c5c045 100644
--- a/components/console/navbar.tsx
+++ b/components/console/navbar.tsx
@@ -1,4 +1,3 @@
-import type { Organization } from "@/lib/ops/auth";
import Image from "next/image";
import Link from "next/link";
import logo from "../../public/images/logo.png";
@@ -6,21 +5,19 @@ import { OrgSwitcher, UserButton } from "../core/auth";
import NavBarLinks from "./navbar-links";
export default function NavBar({
- orgs,
- activeOrg,
+ activeOrgId,
+ activeOrgSlug,
}: {
- orgs: Organization[];
- activeOrg: Organization | null;
+ activeOrgId: string;
+ activeOrgSlug: string;
}) {
- const orgSlug = "personal";
-
return (
<>