-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚸 Improve magic link sign in experience
New email and sign in feedback
- Loading branch information
1 parent
4ae9ea3
commit 48db171
Showing
7 changed files
with
129 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/builder/src/pages/api/auth/sendVerificationRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { EmailConfig } from 'next-auth/providers/email' | ||
import { sendMagicLinkEmail } from 'emails' | ||
|
||
type Props = { | ||
identifier: string | ||
url: string | ||
provider: Partial<Omit<EmailConfig, 'options'>> | ||
} | ||
|
||
export const sendVerificationRequest = async ({ identifier, url }: Props) => { | ||
try { | ||
await sendMagicLinkEmail({ url, to: identifier }) | ||
} catch (err) { | ||
throw new Error(`Email(s) could not be sent`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { ComponentProps } from 'react' | ||
import { | ||
Mjml, | ||
MjmlBody, | ||
MjmlSection, | ||
MjmlColumn, | ||
MjmlSpacer, | ||
} from '@faire/mjml-react' | ||
import { render } from '@faire/mjml-react/utils/render' | ||
import { HeroImage, Text, Button, Head } from '../components' | ||
import { SendMailOptions } from 'nodemailer' | ||
import { sendEmail } from '../sendEmail' | ||
|
||
type Props = { | ||
url: string | ||
} | ||
|
||
export const MagicLinkEmail = ({ url }: Props) => ( | ||
<Mjml> | ||
<Head /> | ||
<MjmlBody width={600}> | ||
<MjmlSection padding="0"> | ||
<MjmlColumn> | ||
<HeroImage src="https://s3.fr-par.scw.cloud/typebot/public/typebots/rxp84mn10va5iqek63enrg99/blocks/yfazs53p6coxe4u3tbbvkl0m" /> | ||
</MjmlColumn> | ||
</MjmlSection> | ||
<MjmlSection padding="0 24px" cssClass="smooth"> | ||
<MjmlColumn> | ||
<Text>Here is your magic link 👇</Text> | ||
<MjmlSpacer /> | ||
<Button link={url} align="center"> | ||
Click here to sign in | ||
</Button> | ||
<Text> | ||
If you didn't request this, please ignore this email. | ||
</Text> | ||
<Text> | ||
Best, | ||
<br />- Typebot Team. | ||
</Text> | ||
</MjmlColumn> | ||
</MjmlSection> | ||
</MjmlBody> | ||
</Mjml> | ||
) | ||
|
||
export const sendMagicLinkEmail = ({ | ||
to, | ||
...props | ||
}: Pick<SendMailOptions, 'to'> & ComponentProps<typeof MagicLinkEmail>) => | ||
sendEmail({ | ||
to, | ||
subject: 'Sign in to Typebot', | ||
html: render(<MagicLinkEmail {...props} />).html, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters