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.

wip

Kiran Kcaac674ad4e3
diff --git a/apps/web/app/api/auth/account-exists/route.ts b/apps/web/app/api/auth/account-exists/route.ts
index 3bca742f5e..b260f3cfc2 100644
--- a/apps/web/app/api/auth/account-exists/route.ts
+++ b/apps/web/app/api/auth/account-exists/route.ts
@@ -22,21 +22,27 @@ export async function POST(req: NextRequest) {
}
if (!process.env.NEXT_PUBLIC_IS_DUB) {
- return NextResponse.json({ exists: true });
+ return NextResponse.json({ accountExists: true, hasPassword: true });
}
const user = await conn
- .execute("SELECT email FROM User WHERE email = ?", [email])
+ .execute("SELECT email, passwordHash FROM User WHERE email = ?", [email])
.then((res) => res.rows[0]);
if (user) {
- return NextResponse.json({ exists: true });
+ return NextResponse.json({
+ accountExists: true,
+ hasPassword: !!user.passwordHash,
+ });
}
const whitelisted = await isWhitelistedEmail(email);
if (whitelisted) {
- return NextResponse.json({ exists: true });
+ return NextResponse.json({
+ accountExists: true,
+ hasPassword: false,
+ });
}
- return NextResponse.json({ exists: false });
+ return NextResponse.json({ accountExists: false, hasPassword: false });
}
diff --git a/apps/web/app/app.dub.co/(auth)/login/form.tsx b/apps/web/app/app.dub.co/(auth)/login/form.tsx
index aafe9c4ce4..6772148e76 100644
--- a/apps/web/app/app.dub.co/(auth)/login/form.tsx
+++ b/apps/web/app/app.dub.co/(auth)/login/form.tsx
@@ -6,7 +6,14 @@ import {
LastUsedAuthMethodTooltip,
setLastUsedAuthMethod,
} from "@/lib/auth/last-used-method";
-import { Button, Github, Google, InfoTooltip, useMediaQuery } from "@dub/ui";
+import {
+ Button,
+ Github,
+ Google,
+ InfoTooltip,
+ Input,
+ useMediaQuery,
+} from "@dub/ui";
import { Lock, Mail } from "lucide-react";
import { signIn } from "next-auth/react";
import Link from "next/link";
@@ -18,9 +25,11 @@ export default function LoginForm() {
const searchParams = useSearchParams();
const next = searchParams?.get("next");
const [showEmailOption, setShowEmailOption] = useState(false);
+ const [showPasswordField, setShowPasswordField] = useState(false);
const [showSSOOption, setShowSSOOption] = useState(false);
const [noSuchAccount, setNoSuchAccount] = useState(false);
const [email, setEmail] = useState("");
+ const [password, setPassword] = useState("");
const [clickedGoogle, setClickedGoogle] = useState(false);
const [clickedGithub, setClickedGithub] = useState(false);
const [clickedEmail, setClickedEmail] = useState(false);
@@ -151,6 +160,12 @@ export default function LoginForm() {
</div>
)}
+ {showPasswordField && (
+ <div>
+ <Input type="password" placeholder="Password" value={password} />
+ </div>
+ )}
+
<div className="relative">
<Button
text="Continue with Email"
@@ -171,6 +186,7 @@ export default function LoginForm() {
{authMethod === "email" && <LastUsedAuthMethodTooltip />}
</div>
</form>
+
<form
onSubmit={async (e) => {
e.preventDefault();
diff --git a/apps/web/app/app.dub.co/(auth)/login/page.tsx b/apps/web/app/app.dub.co/(auth)/login/page.tsx
index ce7ed1b84d..b5fe7ff17f 100644
--- a/apps/web/app/app.dub.co/(auth)/login/page.tsx
+++ b/apps/web/app/app.dub.co/(auth)/login/page.tsx
@@ -2,7 +2,6 @@ import { Button, Logo } from "@dub/ui";
import { HOME_DOMAIN, constructMetadata } from "@dub/utils";
import { Suspense } from "react";
import LoginForm from "./form";
-import { SignInWithEmailPassword } from "./signin-email-password";
export const metadata = constructMetadata({
title: `Sign in to ${process.env.NEXT_PUBLIC_APP_NAME}`,
@@ -23,8 +22,6 @@ export default function LoginPage() {
</p>
</div>
<div className="flex flex-col bg-gray-50 px-4 py-8 sm:px-16">
- <SignInWithEmailPassword />
- <div className="my-8 border-t border-gray-300 bg-red-300" />
<div className="space-y-3">
<Suspense
fallback={