more system tests as login is borked
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 19s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 19s
This commit is contained in:
@@ -33,18 +33,35 @@ export const SignUpModal: React.FC<SignUpModalProps> = ({ isOpen, onClose, onSwi
|
||||
setError(null);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
const { error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
options: { emailRedirectTo: window.location.href }
|
||||
});
|
||||
if (error) throw error;
|
||||
setMessage('Check your email for the confirmation link!');
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'An unexpected error occurred.');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
// Check if there is a current anonymous session
|
||||
const { data: { session } } = await supabase.auth.getSession();
|
||||
|
||||
if (session && session.user.is_anonymous) {
|
||||
// If the user is anonymous, upgrade their account instead of creating a new one.
|
||||
try {
|
||||
const { error } = await supabase.auth.updateUser({ email, password });
|
||||
if (error) throw error;
|
||||
setMessage('Your account has been created! Check your email for a confirmation link.');
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'An unexpected error occurred during account upgrade.');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
} else {
|
||||
// Standard sign-up flow for new users.
|
||||
try {
|
||||
const { error } = await supabase.auth.signUp({
|
||||
email,
|
||||
password,
|
||||
options: { emailRedirectTo: window.location.href }
|
||||
});
|
||||
if (error) throw error;
|
||||
setMessage('Check your email for the confirmation link!');
|
||||
} catch (err: any) {
|
||||
setError(err.message || 'An unexpected error occurred.');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user