diff --git a/src/lib/app_components/e_app_sign_in_out.svelte b/src/lib/app_components/e_app_sign_in_out.svelte index 39dd9322..63b1bd76 100644 --- a/src/lib/app_components/e_app_sign_in_out.svelte +++ b/src/lib/app_components/e_app_sign_in_out.svelte @@ -73,6 +73,9 @@ let is_changing_password = $state(false); let show_password_text = $state('password'); // password or text + // Email sign-in status: null | 'sending' | 'sent' | 'not_found' | 'error' + let email_send_status: null | string = $state(null); + function sign_in() { $ae_loc.jwt = user_obj.jwt; // Store the JSON Web Token $ae_loc.person_id = person_id; // Set the person_id in the ae_loc store @@ -231,17 +234,19 @@ .then((user_response) => { if (user_response?.user_id_random) { console.log(`User found for email:`, user_response); - handle_send_auth_email({ - user_id: user_response.user_id_random - }); + handle_send_auth_email({ user_id: user_response.user_id_random }); + email_send_status = 'sent'; } else if (user_response && user_response.length > 0) { console.log(`Multiple users found for email:`, user_response); - handle_send_auth_email({ - user_id: user_response[0].user_id_random - }); + handle_send_auth_email({ user_id: user_response[0].user_id_random }); + email_send_status = 'sent'; } else { - alert('No user found with that email address.'); + console.warn('No user found for email:', email); + email_send_status = 'not_found'; } + }) + .catch(() => { + email_send_status = 'error'; }); } @@ -378,12 +383,12 @@ onsubmit={async (e) => { e.preventDefault(); if ($ae_sess.auth__entered_email) { - alert('Attempting to look up user by email address.'); + email_send_status = 'sending'; handle_lookup_user_email({ email: $ae_sess.auth__entered_email }); } else { - alert('Please enter an email address to look up.'); + email_send_status = 'no_email'; } }} > @@ -397,11 +402,31 @@ />