Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

chore: Update user route to remove passwordHash from response

Kiran Kb0471a0202da
diff --git a/apps/web/app/api/user/route.ts b/apps/web/app/api/user/route.ts
index dc6461bbfc..bf192aeeb3 100644
--- a/apps/web/app/api/user/route.ts
+++ b/apps/web/app/api/user/route.ts
@@ -51,6 +51,7 @@ export const GET = withSession(async ({ session }) => {
migratedWorkspace,
provider: account?.provider,
hasPassword: user?.passwordHash !== null,
+ passwordHash: undefined,
});
});
diff --git a/apps/web/app/app.dub.co/(dashboard)/settings/security/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/settings/security/page-client.tsx
new file mode 100644
index 0000000000..6a5605f66c
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/settings/security/page-client.tsx
@@ -0,0 +1,18 @@
+"use client";
+
+import useUser from "@/lib/swr/use-user";
+import { LoadingSpinner } from "@dub/ui";
+import { RequestSetPassword } from "./request-set-password";
+import { UpdatePassword } from "./update-password";
+
+export const dynamic = "force-dynamic";
+
+export default function SecurityPageClient() {
+ const { loading, user } = useUser();
+
+ if (loading) {
+ return <LoadingSpinner />;
+ }
+
+ return <>{user?.hasPassword ? <UpdatePassword /> : <RequestSetPassword />}</>;
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/settings/security/page.tsx b/apps/web/app/app.dub.co/(dashboard)/settings/security/page.tsx
index f685fc60a5..c40e443375 100644
--- a/apps/web/app/app.dub.co/(dashboard)/settings/security/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/settings/security/page.tsx
@@ -1,34 +1,5 @@
-import { getSession } from "@/lib/auth";
-import { prisma } from "@/lib/prisma";
-import { RequestSetPassword } from "./request-set-password";
-import { UpdatePassword } from "./update-password";
-
-export const runtime = "nodejs";
-export const dynamic = "force-dynamic";
+import SecurityPageClient from "./page-client";
export default async function SecurityPage() {
- const user = await getUser();
-
- return <>{user.hasPassword ? <UpdatePassword /> : <RequestSetPassword />}</>;
+ return <SecurityPageClient />;
}
-
-const getUser = async () => {
- const session = await getSession();
-
- if (!session) {
- throw new Error("Unauthorized");
- }
-
- const user = await prisma.user.findFirstOrThrow({
- where: {
- id: session.user.id,
- },
- select: {
- passwordHash: true,
- },
- });
-
- return {
- hasPassword: user.passwordHash !== null,
- };
-};
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index fe2f6529c1..37ccb9bd27 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -13,7 +13,6 @@ import EmailProvider from "next-auth/providers/email";
import GithubProvider from "next-auth/providers/github";
import GoogleProvider from "next-auth/providers/google";
import { cookies } from "next/headers";
-import { ratelimitOrThrow } from "../api/utils";
import { dub } from "../dub";
import { subscribe } from "../flodesk";
import { isStored, storage } from "../storage";
@@ -193,9 +192,6 @@ export const authOptions: NextAuthOptions = {
throw new Error("no-credentials");
}
- // @ts-ignore
- await ratelimitOrThrow(req, "login-with-credentials");
-
const user = await prisma.user.findUnique({
where: { email },
select: {