diff --git a/app/(customer)/dashboard/(organization)/settings/page.tsx b/app/(customer)/dashboard/(organization)/settings/page.tsx
index 406cb155..83aafd1e 100644
--- a/app/(customer)/dashboard/(organization)/settings/page.tsx
+++ b/app/(customer)/dashboard/(organization)/settings/page.tsx
@@ -17,7 +17,6 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
const user = await currentUser();
const activeMember = await getActiveMember()
-
if (!organization) {
notFound();
}
@@ -35,12 +34,12 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
Organization settings
{!isMember && organization.slug !== "default" && (
-
+
)}
{!isMember && organization.slug !== "default" && (
-
+
)}
@@ -48,7 +47,7 @@ export default async function RoutePage(props: PageParams<{ slug: string }>) {
{/* Manage your organization settings.*/}
{/**/}
-
+
)
diff --git a/src/components/wrappers/dashboard/organization/delete-organization/delete-organization-button.tsx b/src/components/wrappers/dashboard/organization/delete-organization/delete-organization-button.tsx
index aa706fce..63edd168 100644
--- a/src/components/wrappers/dashboard/organization/delete-organization/delete-organization-button.tsx
+++ b/src/components/wrappers/dashboard/organization/delete-organization/delete-organization-button.tsx
@@ -22,8 +22,8 @@ export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) =
organizationSlug: "default",
});
router.push("/");
-
toast.success(result.data.actionSuccess?.message || "Organization deleted.");
+ router.refresh()
} else {
// @ts-ignore
const errorMsg = result?.data?.actionError?.message || result?.data?.actionError?.messageParams?.message || "Failed to delete the organization.";
diff --git a/src/components/wrappers/dashboard/organization/organization.action.ts b/src/components/wrappers/dashboard/organization/organization.action.ts
index 68774539..e5bb4e5e 100644
--- a/src/components/wrappers/dashboard/organization/organization.action.ts
+++ b/src/components/wrappers/dashboard/organization/organization.action.ts
@@ -222,7 +222,13 @@ export const deleteOrganizationAction = userAction.schema(z.string()).action(
let deletedOrganization: Organization;
try {
- deletedOrganization = await deleteOrganization(org.id) as Organization;
+ // TODO : Improve with better auth, always getting 403 error
+ // deletedOrganization = await deleteOrganization(org.id) as Organization;
+ [deletedOrganization] = await db
+ .delete(drizzleDb.schemas.organization)
+ .where(eq(drizzleDb.schemas.organization.id, org.id))
+ .returning();
+
} catch (authError: any) {
console.error("Auth deletion failed:", authError);
return {
diff --git a/src/components/wrappers/dashboard/profile/button-delete-account/delete-account.action.ts b/src/components/wrappers/dashboard/profile/button-delete-account/delete-account.action.ts
index d8eb4438..7e44513f 100644
--- a/src/components/wrappers/dashboard/profile/button-delete-account/delete-account.action.ts
+++ b/src/components/wrappers/dashboard/profile/button-delete-account/delete-account.action.ts
@@ -5,24 +5,32 @@ import { v4 as uuidv4 } from "uuid";
import { db } from "@/db";
import { eq } from "drizzle-orm";
import * as drizzleDb from "@/db";
+import {authClient} from "@/lib/auth/auth-client";
+import {auth} from "@/lib/auth/auth";
export const deleteUserAction = userAction.schema(z.string()).action(async ({ parsedInput, ctx }) => {
const userId = parsedInput.length > 0 ? parsedInput : ctx.user.id;
const uuid = uuidv4();
- const [updatedUser] = await db
- .update(drizzleDb.schemas.user)
- .set({
- email: `${uuid}@portabase.com`,
- name: `${uuid}`,
- //deleted: true,
- //todo: add deleted
- })
+
+ // const [updatedUser] = await db
+ // .update(drizzleDb.schemas.user)
+ // .set({
+ // email: `${uuid}@portabase.com`,
+ // name: `${uuid}`,
+ // //deleted: true,
+ // //todo: add deleted
+ // })
+ // .where(eq(drizzleDb.schemas.user.id, userId))
+ // .returning();
+ const [deletedUser] = await db
+ .delete(drizzleDb.schemas.user)
.where(eq(drizzleDb.schemas.user.id, userId))
.returning();
+
return {
- data: updatedUser,
+ data: deletedUser,
};
});
diff --git a/src/lib/auth/permissions.ts b/src/lib/auth/permissions.ts
index 145e7929..a08b5235 100644
--- a/src/lib/auth/permissions.ts
+++ b/src/lib/auth/permissions.ts
@@ -19,8 +19,7 @@ const superadmin = ac.newRole({
...adminAc.statements,
...orgAdminAc.statements,
...orgOwnerAc.statements,
- ...orgMemberAc.statements
-
+ ...orgMemberAc.statements,
});
const admin = ac.newRole({