fix: resolve email verification timing issue by sending to newly created user
This commit is contained in:
1 parent
825156a53a
commit
acdc219ad3
3 files changed
+20
-12
No files matched your search
@@ -18,7 +18,7 @@ export default function Login() {
|
||||
const [forgotMessage, setForgotMessage] = useState('');
|
||||
const [showVerificationBanner, setShowVerificationBanner] = useState(false);
|
||||
const [verificationSent, setVerificationSent] = useState(false);
|
||||
const { login, signup, sendPasswordReset, sendVerificationEmail } = useAuth();
|
||||
const { login, signup, sendPasswordReset, sendVerificationEmailToUser } = useAuth();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -37,14 +37,16 @@ export default function Login() {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await signup(email, password, firstName);
|
||||
// Send verification email
|
||||
try {
|
||||
await sendVerificationEmail();
|
||||
setVerificationSent(true);
|
||||
setShowVerificationBanner(true);
|
||||
} catch (err) {
|
||||
console.error('Error sending verification email:', err);
|
||||
const newUser = await signup(email, password, firstName);
|
||||
// Send verification email to the newly created user
|
||||
if (newUser) {
|
||||
try {
|
||||
await sendVerificationEmailToUser(newUser);
|
||||
setVerificationSent(true);
|
||||
setShowVerificationBanner(true);
|
||||
} catch (err) {
|
||||
console.error('Error sending verification email:', err);
|
||||
}
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
setError(err instanceof Error ? err.message : 'An error occurred');
|
||||
|
||||
Reference in new issue
Block a user