Skip to content
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

Forgot password flow #12

Open
TimMikeladze opened this issue Sep 16, 2024 · 6 comments
Open

Forgot password flow #12

TimMikeladze opened this issue Sep 16, 2024 · 6 comments

Comments

@TimMikeladze
Copy link

At the moment it's not possible to reset a forgotten password.

I suggest a basic reset password flow by sending the user a password reset link to their email.

Maybe using resend? But should be easily swappable with other email libraries.

@leerob
Copy link
Collaborator

leerob commented Sep 16, 2024

💯 I am thinking we'd use Resend and react-email for both this, as well as the team invite flow.

https://github.com/leerob/next-saas-starter/blob/afff269d7ad8d6b90f5bf2c50dbf15b2ebc285d6/app/(login)/actions.ts#L417-L420
https://github.com/resend/react-email/tree/main/examples/resend

@MJomaa
Copy link
Contributor

MJomaa commented Sep 17, 2024

@leerob Yes please! react-email is also very easy, I can add it to the repo.

My favorite is the Vercel theme:

@atikkk
Copy link

atikkk commented Sep 18, 2024

hey @leerob can you please help me in local setup?

@jonkurtis
Copy link
Contributor

hey @leerob can you please help me in local setup?

where are you getting stuck? The PR I made might be helpful. #14

@samueltesfayegari
Copy link

hey @leerob can you please help me in local setup?

Yes tutorial Video missing 🙌

@sanjomathew09
Copy link

// Get references to the form and its elements
const form = document.getElementById('forgot-password-form');
const emailInput = document.getElementById('email');
const errorMessage = document.getElementById('error-message');

// Email validation regex
const emailRegex = /^[^\s@]+@[^\s@]+.[^\s@]+$/;

// Handle form submission
form.addEventListener('submit', (e) => {
e.preventDefault(); // Prevent the default form submission

const email = emailInput.value.trim();

// Validate the email input
if (!emailRegex.test(email)) {
errorMessage.style.display = 'block';
return;
}

// Hide the error message if validation passes
errorMessage.style.display = 'none';

// Simulate sending a reset link (replace with actual API call)
alert(A password reset link has been sent to: ${email});
emailInput.value = ''; // Clear the input field
});

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

No branches or pull requests

7 participants