Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

add email and linkedin signup

Marc Seitze7c268d3b13e
diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx
index 022528be..84979a52 100644
--- a/app/(auth)/login/page.tsx
+++ b/app/(auth)/login/page.tsx
@@ -10,6 +10,7 @@ import { useParams } from "next/navigation";
import Passkey from "@/components/shared/icons/passkey";
import { useState } from "react";
import { toast } from "sonner";
+import LinkedIn from "@/components/shared/icons/linkedin";
export default function Login() {
const { next } = useParams as { next?: string };
@@ -87,6 +88,17 @@ export default function Login() {
</svg>
<span>Continue with Google</span>
</Button>
+ <Button
+ onClick={() => {
+ signIn("linkedin", {
+ ...(next && next.length > 0 ? { callbackUrl: next } : {}),
+ });
+ }}
+ className="flex justify-center items-center space-x-2"
+ >
+ <LinkedIn />
+ <span>Continue with LinkedIn</span>
+ </Button>
<Button
onClick={() =>
signInWithPasskey({
diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx
index b3a46a8b..630a6530 100644
--- a/app/(auth)/register/page.tsx
+++ b/app/(auth)/register/page.tsx
@@ -3,33 +3,16 @@
import { Button } from "@/components/ui/button";
import { signIn } from "next-auth/react";
import Link from "next/link";
-import { useRouter, useParams } from "next/navigation";
-import Passkey from "@/components/shared/icons/passkey";
-import {
- finishServerPasskeyRegistration,
- startServerPasskeyRegistration,
-} from "@/lib/api/auth/passkey";
-import { create } from "@github/webauthn-json";
+import { useParams } from "next/navigation";
import { Input } from "@/components/ui/input";
import { useState } from "react";
import { toast } from "sonner";
export default function Register() {
- const router = useRouter();
const { next } = useParams as { next?: string };
const [email, setEmail] = useState<string>("");
- async function registerPasskey() {
- const createOptions = await startServerPasskeyRegistration();
-
- // Open "register passkey" dialog
- const credential = await create(createOptions as any);
-
- await finishServerPasskeyRegistration(credential);
- // Now the user has registered their passkey and can use it to log in.
- }
-
return (
<div className="flex h-screen w-screen justify-center">
<div
@@ -44,7 +27,7 @@ export default function Register() {
}}
/>
</div>
- <div className="z-10 mt-[calc(30vh)] h-fit w-full mx-5 sm:mx-0 max-w-md overflow-hidden border border-border bg-gray-50 dark:bg-gray-900 rounded-lg sm:shadow-xl">
+ <div className="z-10 mt-[calc(20vh)] h-fit w-full mx-5 sm:mx-0 max-w-md overflow-hidden border border-border bg-gray-50 dark:bg-gray-900 rounded-lg sm:shadow-xl">
<div className="flex flex-col items-center justify-center space-y-3 px-4 py-6 pt-8 text-center sm:px-16">
<Link href="/">
<span className="text-xl font-bold tracking-tighter text-foreground">
@@ -101,13 +84,24 @@ export default function Register() {
</svg>
<span>Continue with Google</span>
</Button>
- {/* <Button
- onClick={() => registerPasskey().then(router.refresh)}
+ <Button
+ onClick={() => {
+ signIn("linkedin", {
+ ...(next && next.length > 0 ? { callbackUrl: next } : {}),
+ });
+ }}
className="flex justify-center items-center space-x-2"
>
- <Passkey className="w-4 h-4" />
- <span>Register a passkey</span>
- </Button> */}
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 488 512"
+ fill="currentColor"
+ className="h-4 w-4"
+ >
+ <path d="M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z" />
+ </svg>
+ <span>Continue with LinkedIn</span>
+ </Button>
</div>
</div>
</div>
diff --git a/components/shared/icons/linkedin.tsx b/components/shared/icons/linkedin.tsx
new file mode 100644
index 00000000..c7c45505
--- /dev/null
+++ b/components/shared/icons/linkedin.tsx
@@ -0,0 +1,23 @@
+export default function LinkedIn({ className }: { className?: string }) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="16"
+ height="16"
+ viewBox="0 0 256 256"
+ className={className}
+ shapeRendering="geometricPrecision"
+ >
+ <g>
+ <path
+ d="M0 18.338C0 8.216 8.474 0 18.92 0h218.16C247.53 0 256 8.216 256 18.338v219.327C256 247.79 247.53 256 237.08 256H18.92C8.475 256 0 247.791 0 237.668V18.335z"
+ fill="#000"
+ />
+ <path
+ d="M77.796 214.238V98.986H39.488v115.252H77.8zM58.65 83.253c13.356 0 21.671-8.85 21.671-19.91-.25-11.312-8.315-19.915-21.417-19.915-13.111 0-21.674 8.603-21.674 19.914 0 11.06 8.312 19.91 21.169 19.91h.248zM99 214.238h38.305v-64.355c0-3.44.25-6.889 1.262-9.346 2.768-6.885 9.071-14.012 19.656-14.012 13.858 0 19.405 10.568 19.405 26.063v61.65h38.304v-66.082c0-35.399-18.896-51.872-44.099-51.872-20.663 0-29.738 11.549-34.78 19.415h.255V98.99H99.002c.5 10.812-.003 115.252-.003 115.252z"
+ fill="#fff"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/pages/api/auth/[...nextauth].ts b/pages/api/auth/[...nextauth].ts
index 3fa023f4..633fdc1b 100644
--- a/pages/api/auth/[...nextauth].ts
+++ b/pages/api/auth/[...nextauth].ts
@@ -1,13 +1,14 @@
import NextAuth, { type NextAuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";
+import LinkedInProvider from "next-auth/providers/linkedin";
+import EmailProvider from "next-auth/providers/email";
+import { PasskeyProvider } from "@teamhanko/passkeys-next-auth-provider";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "@/lib/prisma";
import { CreateUserEmailProps, CustomUser } from "@/lib/types";
import { sendWelcomeEmail } from "@/lib/emails/send-welcome";
import { analytics, identifyUser, trackAnalytics } from "@/lib/analytics";
-import EmailProvider from "next-auth/providers/email";
import { sendVerificationRequestEmail } from "@/lib/emails/send-verification-request";
-import { PasskeyProvider } from "@teamhanko/passkeys-next-auth-provider";
import hanko from "@/lib/hanko";
const VERCEL_DEPLOYMENT = !!process.env.VERCEL_URL;
@@ -18,10 +19,34 @@ export const config = {
};
export const authOptions: NextAuthOptions = {
+ pages: {
+ error: "/login",
+ },
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
+ allowDangerousEmailAccountLinking: true,
+ }),
+ LinkedInProvider({
+ clientId: process.env.LINKEDIN_CLIENT_ID as string,
+ clientSecret: process.env.LINKEDIN_CLIENT_SECRET as string,
+ authorization: {
+ params: { scope: "openid profile email" },
+ },
+ issuer: "https://www.linkedin.com",
+ jwks_endpoint: "https://www.linkedin.com/oauth/openid/jwks",
+ profile(profile, tokens) {
+ const defaultImage =
+ "https://cdn-icons-png.flaticon.com/512/174/174857.png";
+ return {
+ id: profile.sub,
+ name: profile.name,
+ email: profile.email,
+ image: profile.picture ?? defaultImage,
+ };
+ },
+ allowDangerousEmailAccountLinking: true,
}),
EmailProvider({
async sendVerificationRequest({ identifier, url }) {