💬 🗃️ user signup source and viral signup links

This commit is contained in:
Timur Ercan
2023-02-23 20:02:33 +01:00
parent fb31156e80
commit 40a32073dd
7 changed files with 27 additions and 6 deletions

View File

@ -14,7 +14,7 @@ type FormValues = {
apiError: string; apiError: string;
}; };
export default function Signup() { export default function Signup(props: { source: string }) {
const methods = useForm<FormValues>({}); const methods = useForm<FormValues>({});
const { const {
register, register,
@ -34,6 +34,7 @@ export default function Signup() {
.promise( .promise(
fetch("/api/auth/signup", { fetch("/api/auth/signup", {
body: JSON.stringify({ body: JSON.stringify({
source: props.source,
...data, ...data,
}), }),
headers: { headers: {

View File

@ -6,8 +6,7 @@ import { hashPassword } from "@documenso/lib/auth";
import { defaultHandler, defaultResponder } from "@documenso/lib/server"; import { defaultHandler, defaultResponder } from "@documenso/lib/server";
async function postHandler(req: NextApiRequest, res: NextApiResponse) { async function postHandler(req: NextApiRequest, res: NextApiResponse) {
const data = req.body; const { email, password, source } = req.body;
const { email, password } = data;
const cleanEmail = email.toLowerCase(); const cleanEmail = email.toLowerCase();
if (!cleanEmail || !cleanEmail.includes("@")) { if (!cleanEmail || !cleanEmail.includes("@")) {
@ -46,6 +45,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
email: cleanEmail, email: cleanEmail,
password: hashedPassword, password: hashedPassword,
identityProvider: IdentityProvider.DOCUMENSO, identityProvider: IdentityProvider.DOCUMENSO,
source: source,
}, },
}); });

View File

@ -67,7 +67,10 @@ const SignPage: NextPageWithLayout = (props: any) => {
</div> </div>
<p className="mt-4 text-center text-sm text-gray-600"> <p className="mt-4 text-center text-sm text-gray-600">
Want to send slick signing links like this one?{" "} Want to send slick signing links like this one?{" "}
<Link href="/signup" className="font-medium text-neon hover:text-neon"> <Link
href="/signup?source=signed"
className="font-medium text-neon hover:text-neon"
>
Create your own Account Create your own Account
</Link> </Link>
</p> </p>

View File

@ -1,13 +1,23 @@
import { NextPageContext } from "next";
import Head from "next/head"; import Head from "next/head";
import Signup from "../components/signup"; import Signup from "../components/signup";
export default function SignupPage() { export default function SignupPage(props: { source: string }) {
return ( return (
<> <>
<Head> <Head>
<title>Signup | Documenso</title> <title>Signup | Documenso</title>
</Head> </Head>
<Signup></Signup> <Signup source={props.source}></Signup>
</> </>
); );
} }
export async function getServerSideProps(context: any) {
const signupSource: string = context.query["source"];
return {
props: {
source: signupSource ? signupSource : "",
},
};
}

View File

@ -15,6 +15,9 @@ export const signingCompleteTemplate = (message: string) => {
<p style="margin-top: 14px;"> <p style="margin-top: 14px;">
A copy of the signed document has been attached to this email. A copy of the signed document has been attached to this email.
</p>
<p style="margin-top: 14px;">
<small>Like Documenso? <a href="https://app.documenso.com/signup?source=completemail">Create your own acccount</a>.</small>
</p>`; </p>`;
const html = baseEmailTemplate(message, customContent); const html = baseEmailTemplate(message, customContent);

View File

@ -16,6 +16,9 @@ export const signingRequestTemplate = (
${ctaLabel} ${ctaLabel}
</a> </a>
</p> </p>
<p style="margin-top: 14px;">
<small>Want to send you own signing links? <a href="https://app.documenso.com/signup?source=signrequest">Create your own acccount</a>.</small>
</p>
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0"> <hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
Click the button to view "${document.title}".<br> Click the button to view "${document.title}".<br>
<small>If you have questions about this document, you should ask ${user.name}.</small> <small>If you have questions about this document, you should ask ${user.name}.</small>

View File

@ -18,6 +18,7 @@ model User {
email String @unique email String @unique
emailVerified DateTime? emailVerified DateTime?
password String? password String?
source String?
identityProvider IdentityProvider @default(DOCUMENSO) identityProvider IdentityProvider @default(DOCUMENSO)
accounts Account[] accounts Account[]
sessions Session[] sessions Session[]