diff --git a/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx
index ceeb386d..458bf563 100644
--- a/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx
+++ b/apps/dokploy/components/dashboard/settings/profile/disable-2fa.tsx
@@ -61,7 +61,7 @@ export const Disable2FA = () => {
}
toast.success("2FA disabled successfully");
- utils.auth.get.invalidate();
+ utils.user.get.invalidate();
setIsOpen(false);
} catch (_error) {
form.setError("password", {
diff --git a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx
index 28fba67d..f47c8d9c 100644
--- a/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx
+++ b/apps/dokploy/components/dashboard/settings/profile/enable-2fa.tsx
@@ -125,7 +125,7 @@ export const Enable2FA = () => {
}
toast.success("2FA configured successfully");
- utils.auth.get.invalidate();
+ utils.user.get.invalidate();
setIsDialogOpen(false);
} catch (error) {
if (error instanceof Error) {
diff --git a/apps/dokploy/components/dashboard/settings/profile/generate-token.tsx b/apps/dokploy/components/dashboard/settings/profile/generate-token.tsx
index d0299eb6..4d36ab7a 100644
--- a/apps/dokploy/components/dashboard/settings/profile/generate-token.tsx
+++ b/apps/dokploy/components/dashboard/settings/profile/generate-token.tsx
@@ -17,7 +17,7 @@ export const GenerateToken = () => {
const { data, refetch } = api.user.get.useQuery();
const { mutateAsync: generateToken, isLoading: isLoadingToken } =
- api.auth.generateToken.useMutation();
+ api.user.generateToken.useMutation();
return (
@@ -51,7 +51,7 @@ export const GenerateToken = () => {
diff --git a/apps/dokploy/components/dashboard/settings/profile/remove-self-account.tsx b/apps/dokploy/components/dashboard/settings/profile/remove-self-account.tsx
deleted file mode 100644
index 93501994..00000000
--- a/apps/dokploy/components/dashboard/settings/profile/remove-self-account.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-import { AlertBlock } from "@/components/shared/alert-block";
-import { DialogAction } from "@/components/shared/dialog-action";
-import { Button } from "@/components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/components/ui/form";
-import { Input } from "@/components/ui/input";
-import { api } from "@/utils/api";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { useTranslation } from "next-i18next";
-import { useRouter } from "next/router";
-import { useEffect } from "react";
-import { useForm } from "react-hook-form";
-import { toast } from "sonner";
-import { z } from "zod";
-
-const profileSchema = z.object({
- password: z.string().min(1, {
- message: "Password is required",
- }),
-});
-
-type Profile = z.infer;
-
-export const RemoveSelfAccount = () => {
- const { data } = api.user.get.useQuery();
- const { mutateAsync, isLoading, error, isError } =
- api.auth.removeSelfAccount.useMutation();
- const { t } = useTranslation("settings");
- const router = useRouter();
-
- const form = useForm({
- defaultValues: {
- password: "",
- },
- resolver: zodResolver(profileSchema),
- });
-
- useEffect(() => {
- if (data) {
- form.reset({
- password: "",
- });
- }
- form.reset();
- }, [form, form.reset, data]);
-
- const onSubmit = async (values: Profile) => {
- await mutateAsync({
- password: values.password,
- })
- .then(async () => {
- toast.success("Profile Deleted");
- router.push("/");
- })
- .catch(() => {});
- };
-
- return (
-
-
-
-
-
- Remove Self Account
-
- If you want to remove your account, you can do it here
-
-
-
-
- {isError && {error?.message}}
-
-
-
-
- form.handleSubmit(onSubmit)()}
- >
-
-
-
-
-
-
-
- );
-};
diff --git a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx
index b8c69926..9a49277e 100644
--- a/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx
+++ b/apps/dokploy/components/dashboard/settings/servers/setup-monitoring.tsx
@@ -89,7 +89,7 @@ export const SetupMonitoring = ({ serverId }: Props) => {
enabled: !!serverId,
},
)
- : api.user.get.useQuery();
+ : api.user.getServerMetrics.useQuery();
const url = useUrl();
diff --git a/apps/dokploy/components/layouts/side.tsx b/apps/dokploy/components/layouts/side.tsx
index 63155f8e..9c61fb39 100644
--- a/apps/dokploy/components/layouts/side.tsx
+++ b/apps/dokploy/components/layouts/side.tsx
@@ -89,7 +89,7 @@ import { UpdateServerButton } from "./update-server";
import { UserNav } from "./user-nav";
// The types of the queries we are going to use
-type AuthQueryOutput = inferRouterOutputs["auth"]["get"];
+type AuthQueryOutput = inferRouterOutputs["user"]["get"];
type SingleNavItem = {
isSingle?: true;
diff --git a/apps/dokploy/pages/api/[...trpc].ts b/apps/dokploy/pages/api/[...trpc].ts
index df85440b..85ddbb28 100644
--- a/apps/dokploy/pages/api/[...trpc].ts
+++ b/apps/dokploy/pages/api/[...trpc].ts
@@ -1,17 +1,11 @@
import { appRouter } from "@/server/api/root";
import { createTRPCContext } from "@/server/api/trpc";
-import { validateBearerToken, validateRequest } from "@dokploy/server";
+import { validateRequest } from "@dokploy/server";
import { createOpenApiNextHandler } from "@dokploy/trpc-openapi";
import type { NextApiRequest, NextApiResponse } from "next";
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
- let { session, user } = await validateBearerToken(req);
-
- if (!session) {
- const cookieResult = await validateRequest(req, res);
- session = cookieResult.session;
- user = cookieResult.user;
- }
+ const { session, user } = await validateRequest(req);
if (!user || !session) {
res.status(401).json({ message: "Unauthorized" });
diff --git a/apps/dokploy/pages/dashboard/projects.tsx b/apps/dokploy/pages/dashboard/projects.tsx
index 49427c25..5434163a 100644
--- a/apps/dokploy/pages/dashboard/projects.tsx
+++ b/apps/dokploy/pages/dashboard/projects.tsx
@@ -52,7 +52,7 @@ export async function getServerSideProps(
});
await helpers.settings.isCloud.prefetch();
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
if (!user) {
return {
redirect: {
diff --git a/apps/dokploy/pages/dashboard/settings/billing.tsx b/apps/dokploy/pages/dashboard/settings/billing.tsx
index ee1ecdbe..7ba5717e 100644
--- a/apps/dokploy/pages/dashboard/settings/billing.tsx
+++ b/apps/dokploy/pages/dashboard/settings/billing.tsx
@@ -52,7 +52,7 @@ export async function getServerSideProps(
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
diff --git a/apps/dokploy/pages/dashboard/settings/certificates.tsx b/apps/dokploy/pages/dashboard/settings/certificates.tsx
index 96bec90b..0c82ed4f 100644
--- a/apps/dokploy/pages/dashboard/settings/certificates.tsx
+++ b/apps/dokploy/pages/dashboard/settings/certificates.tsx
@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/dashboard/settings/cluster.tsx b/apps/dokploy/pages/dashboard/settings/cluster.tsx
index 77ece29b..a1a46bb6 100644
--- a/apps/dokploy/pages/dashboard/settings/cluster.tsx
+++ b/apps/dokploy/pages/dashboard/settings/cluster.tsx
@@ -53,7 +53,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
return {
props: {
diff --git a/apps/dokploy/pages/dashboard/settings/destinations.tsx b/apps/dokploy/pages/dashboard/settings/destinations.tsx
index 8605a7c1..3c906b55 100644
--- a/apps/dokploy/pages/dashboard/settings/destinations.tsx
+++ b/apps/dokploy/pages/dashboard/settings/destinations.tsx
@@ -46,7 +46,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/dashboard/settings/git-providers.tsx b/apps/dokploy/pages/dashboard/settings/git-providers.tsx
index ce2adc9c..7a9b08df 100644
--- a/apps/dokploy/pages/dashboard/settings/git-providers.tsx
+++ b/apps/dokploy/pages/dashboard/settings/git-providers.tsx
@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
try {
await helpers.project.all.prefetch();
await helpers.settings.isCloud.prefetch();
diff --git a/apps/dokploy/pages/dashboard/settings/index.tsx b/apps/dokploy/pages/dashboard/settings/index.tsx
index 713e5113..4c060cbb 100644
--- a/apps/dokploy/pages/dashboard/settings/index.tsx
+++ b/apps/dokploy/pages/dashboard/settings/index.tsx
@@ -209,7 +209,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
return {
props: {
diff --git a/apps/dokploy/pages/dashboard/settings/notifications.tsx b/apps/dokploy/pages/dashboard/settings/notifications.tsx
index 76566fdf..fbdc2e20 100644
--- a/apps/dokploy/pages/dashboard/settings/notifications.tsx
+++ b/apps/dokploy/pages/dashboard/settings/notifications.tsx
@@ -46,7 +46,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/dashboard/settings/profile.tsx b/apps/dokploy/pages/dashboard/settings/profile.tsx
index 446e6c87..404d400c 100644
--- a/apps/dokploy/pages/dashboard/settings/profile.tsx
+++ b/apps/dokploy/pages/dashboard/settings/profile.tsx
@@ -1,6 +1,5 @@
import { GenerateToken } from "@/components/dashboard/settings/profile/generate-token";
import { ProfileForm } from "@/components/dashboard/settings/profile/profile-form";
-import { RemoveSelfAccount } from "@/components/dashboard/settings/profile/remove-self-account";
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
import { appRouter } from "@/server/api/root";
@@ -15,14 +14,14 @@ import superjson from "superjson";
const Page = () => {
const { data } = api.user.get.useQuery();
- const { data: isCloud } = api.settings.isCloud.useQuery();
+ // const { data: isCloud } = api.settings.isCloud.useQuery();
return (
{(data?.canAccessToAPI || data?.role === "owner") &&
}
- {isCloud &&
}
+ {/* {isCloud &&
} */}
);
@@ -53,15 +52,7 @@ export async function getServerSideProps(
});
await helpers.settings.isCloud.prefetch();
- await helpers.auth.get.prefetch();
- if (user?.role === "member") {
- // const userR = await helpers.user.one.fetch({
- // userId: user.id,
- // });
- // await helpers.user.byAuthId.prefetch({
- // authId: user.authId,
- // });
- }
+ await helpers.user.get.prefetch();
if (!user) {
return {
diff --git a/apps/dokploy/pages/dashboard/settings/registry.tsx b/apps/dokploy/pages/dashboard/settings/registry.tsx
index 678e0da4..42f0627f 100644
--- a/apps/dokploy/pages/dashboard/settings/registry.tsx
+++ b/apps/dokploy/pages/dashboard/settings/registry.tsx
@@ -45,7 +45,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/dashboard/settings/server.tsx b/apps/dokploy/pages/dashboard/settings/server.tsx
index 4f88c794..0c5e36dc 100644
--- a/apps/dokploy/pages/dashboard/settings/server.tsx
+++ b/apps/dokploy/pages/dashboard/settings/server.tsx
@@ -110,7 +110,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
return {
props: {
diff --git a/apps/dokploy/pages/dashboard/settings/servers.tsx b/apps/dokploy/pages/dashboard/settings/servers.tsx
index 08d4ab69..5cc30b83 100644
--- a/apps/dokploy/pages/dashboard/settings/servers.tsx
+++ b/apps/dokploy/pages/dashboard/settings/servers.tsx
@@ -56,7 +56,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/dashboard/settings/users.tsx b/apps/dokploy/pages/dashboard/settings/users.tsx
index ac535521..22615314 100644
--- a/apps/dokploy/pages/dashboard/settings/users.tsx
+++ b/apps/dokploy/pages/dashboard/settings/users.tsx
@@ -50,7 +50,7 @@ export async function getServerSideProps(
},
transformer: superjson,
});
- await helpers.auth.get.prefetch();
+ await helpers.user.get.prefetch();
await helpers.settings.isCloud.prefetch();
return {
diff --git a/apps/dokploy/pages/reset-password.tsx b/apps/dokploy/pages/reset-password.tsx
index a34a25ed..0f6cf0b3 100644
--- a/apps/dokploy/pages/reset-password.tsx
+++ b/apps/dokploy/pages/reset-password.tsx
@@ -12,17 +12,13 @@ import {
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
-import { db } from "@/server/db";
-import { auth } from "@/server/db/schema";
-import { api } from "@/utils/api";
+import { authClient } from "@/lib/auth-client";
import { IS_CLOUD } from "@dokploy/server";
import { zodResolver } from "@hookform/resolvers/zod";
-import { isBefore } from "date-fns";
-import { eq } from "drizzle-orm";
import type { GetServerSidePropsContext } from "next";
import Link from "next/link";
import { useRouter } from "next/router";
-import { type ReactElement, useEffect } from "react";
+import { type ReactElement, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
@@ -54,11 +50,12 @@ const loginSchema = z
type Login = z.infer;
interface Props {
- token: string;
+ tokenResetPassword: string;
}
-export default function Home({ token }: Props) {
- const { mutateAsync, isLoading, isError, error } =
- api.auth.resetPassword.useMutation();
+export default function Home({ tokenResetPassword }: Props) {
+ const [token, setToken] = useState(tokenResetPassword);
+ const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState(null);
const router = useRouter();
const form = useForm({
defaultValues: {
@@ -68,26 +65,32 @@ export default function Home({ token }: Props) {
resolver: zodResolver(loginSchema),
});
+ useEffect(() => {
+ const token = new URLSearchParams(window.location.search).get("token");
+
+ if (token) {
+ setToken(token);
+ }
+ }, [token]);
+
useEffect(() => {
form.reset();
}, [form, form.reset, form.formState.isSubmitSuccessful]);
const onSubmit = async (values: Login) => {
- await mutateAsync({
- resetPasswordToken: token,
- password: values.password,
- })
- .then((_data) => {
- toast.success("Password reset successfully", {
- duration: 2000,
- });
- router.push("/");
- })
- .catch(() => {
- toast.error("Error resetting password", {
- duration: 2000,
- });
- });
+ setIsLoading(true);
+ const { error } = await authClient.resetPassword({
+ newPassword: values.password,
+ token: token || "",
+ });
+
+ if (error) {
+ setError(error.message || "An error occurred");
+ } else {
+ toast.success("Password reset successfully");
+ router.push("/");
+ }
+ setIsLoading(false);
};
return (
@@ -104,9 +107,9 @@ export default function Home({ token }: Props) {
- {isError && (
+ {error && (
- {error?.message}
+ {error}
)}