Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add email service and reset password flow #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from

Conversation

jonkurtis
Copy link
Contributor

addresses #12 for password reset flow. also add email service with invite and reset password email templates using resend and react-email.

Copy link

vercel bot commented Sep 25, 2024

@jonkurtis is attempting to deploy a commit to the leerob-site Team on Vercel.

A member of the Team first needs to authorize it.

BrunoSette
BrunoSette approved these changes Sep 27, 2024
@CharlesCCC
Copy link

This will be a great addition. I didn't seem how the email send out ? (Do we need config some sort of smtp or ?)

@patra0o
Copy link

patra0o commented Dec 11, 2024

Great work mate. Wondering about account verification though.
What if I just sign up with a fake mail address that I do not even own?

@CharlesCCC
Copy link

@patra0o +1. I think send verification email after sign-up will be a great addition too.

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-saas-starter ❌ Failed (Inspect) Dec 12, 2024 3:11am

@jonkurtis
Copy link
Contributor Author

This will be a great addition. I didn't seem how the email send out ? (Do we need config some sort of smtp or ?)

it is setup to use Resend. You setup an account at Resend.com and add the api key as shown in .env.example

Resend was suggested as a good solution for this feature by @leerob here #12 (comment)

@jonkurtis
Copy link
Contributor Author

Great work mate. Wondering about account verification though. What if I just sign up with a fake mail address that I do not even own?

thanks.
i think that may be beyond the scope of this PR as that addresses the original Sign Up setup by @leerob prior to this PR. If this gets merged or if @leerob wants it added to get it merged i can address.

@patra0o
Copy link

patra0o commented Dec 12, 2024

Hi @jonkurtis, I am testing out locally.
Plugged in my Resend api key. but I get [{"error":"Failed to send password reset email. Please try again."},"$K1"]
Is there something else I need to change?

react: ResetPasswordEmail({
username,
email: to,
resetPasswordLink: `http://localhost:3000/reset-password?token=${token}`,
Copy link

@CharlesCCC CharlesCCC Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be

 resetPasswordLink: `${process.env.NEXT_PUBLIC_SITE_URL}/reset-password?token=${token}`

@dhiraj-das
Copy link

Hi there. Is there a problem with this PR. Can we please merge it. I really want the invite functionality

@AurelianSpodarec
Copy link

Why hasn't this be merged?

@syntaxsurge
Copy link

can someone please merge this? Thanks

Copy link

@nlinc1905 nlinc1905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be convenient to add the Resend environment variables to lib/db/setup.ts so they are defined from the start. Perhaps add functions like:

async function getResendKey(): Promise<string> {
  console.log('Step 6: Getting Resend Secret Key');
  console.log('You can find your Resend API Key at: https://resend.com/api-keys');
  return await question('Enter your Resend API Key: ');
}

async function getResendEmail(): Promise<string> {
  console.log('Step 7: Getting Resend Secret Email');
  console.log('You can authorize your domain at: https://resend.com/api-keys');
  return await question('Enter an email address for an authorized domain: ');
}

And add them to main():

...
  const RESEND_API_KEY = await getResendKey();
  const RESEND_AUTHORIZED_EMAIL = await getResendEmail();
  const NEXT_PUBLIC_SITE_URL = 'http://localhost:3000';

  await writeEnvFile({
    POSTGRES_URL,
    STRIPE_SECRET_KEY,
    STRIPE_WEBHOOK_SECRET,
    BASE_URL,
    AUTH_SECRET,
    RESEND_API_KEY,
    RESEND_AUTHORIZED_EMAIL,
    NEXT_PUBLIC_SITE_URL,
  });

.limit(1);

if (user.length === 0) {
return { error: 'User not found.' };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For security, it might be better to put all of this in a try/catch, and show a generic error client-side so that hackers don't have an easy way to check if an email exists. The error could still be logged server-side for debugging, or use an environment variable for dev/prod to indicate whether it is safe to display it client-side.

Same thing with forgotPassword above.

@jonkurtis jonkurtis mentioned this pull request Apr 23, 2025
min-Fan added a commit to min-Fan/kol-agent-dapp that referenced this pull request Apr 27, 2025
@max-mapper
Copy link

I was able to rebase this PR again onto main but there was a big dashboard refactor since the last rebase and it was annoying. Would be best for everyone to merge this so it doesn't continue to get out of date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.