mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-07 06:12:31 -06:00
fix: user delete bug (#4550)
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
This commit is contained in:
@@ -31,7 +31,7 @@ const EnvLayout = async (props: {
|
||||
|
||||
const user = await getUser(session.user.id);
|
||||
if (!user) {
|
||||
throw new Error(t("common.user_not_found"));
|
||||
return redirect(`/auth/login`);
|
||||
}
|
||||
|
||||
const hasAccess = await hasUserEnvironmentAccess(session.user.id, params.environmentId);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { getIsFreshInstance } from "@formbricks/lib/instance/service";
|
||||
import { getMembershipByUserIdOrganizationId } from "@formbricks/lib/membership/service";
|
||||
import { getAccessFlags } from "@formbricks/lib/membership/utils";
|
||||
import { getOrganizationsByUserId } from "@formbricks/lib/organization/service";
|
||||
import { getUser } from "@formbricks/lib/user/service";
|
||||
|
||||
const Page = async () => {
|
||||
const session: Session | null = await getServerSession(authOptions);
|
||||
@@ -22,7 +23,8 @@ const Page = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!session?.user) {
|
||||
const user = await getUser(session.user.id);
|
||||
if (!user) {
|
||||
return <ClientLogout />;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,10 @@ import { findMatchingLocale } from "@formbricks/lib/utils/locale";
|
||||
|
||||
export default getRequestConfig(async () => {
|
||||
const session = await getServerSession(authOptions);
|
||||
const locale = session ? await getUserLocale(session.user?.id) : await findMatchingLocale();
|
||||
let locale = session ? await getUserLocale(session.user?.id) : await findMatchingLocale();
|
||||
locale = locale ? locale : DEFAULT_LOCALE;
|
||||
// Lazy load the locale-specific messages
|
||||
const messages = await import(`@formbricks/lib/messages/${locale ?? DEFAULT_LOCALE}.json`).then(
|
||||
(module) => module.default
|
||||
);
|
||||
const messages = await import(`@formbricks/lib/messages/${locale}.json`).then((module) => module.default);
|
||||
|
||||
return {
|
||||
locale,
|
||||
|
||||
@@ -88,7 +88,11 @@ export const DeleteAccountModal = ({
|
||||
)}
|
||||
<li>{t("environments.settings.profile.warning_cannot_undo")}</li>
|
||||
</ul>
|
||||
<form>
|
||||
<form
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
await deleteAccount();
|
||||
}}>
|
||||
<label htmlFor="deleteAccountConfirmation">
|
||||
{t("environments.settings.profile.please_enter_email_to_confirm_account_deletion", {
|
||||
email: user.email,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
"use client";
|
||||
|
||||
import { formbricksLogout } from "@/app/lib/formbricks";
|
||||
import { signOut } from "next-auth/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export const ClientLogout = () => {
|
||||
useEffect(() => {
|
||||
formbricksLogout();
|
||||
signOut();
|
||||
});
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user