A full-featured CRM built with React, shadcn/ui, and Supabase.
Improve user creation error handling.
Matthieu Hochlandera609c6647549
diff --git a/supabase/functions/users/index.ts b/supabase/functions/users/index.tsindex f824cb8d..5719e1fb 100644--- a/supabase/functions/users/index.ts+++ b/supabase/functions/users/index.ts@@ -55,17 +55,22 @@ async function inviteUser(req: Request, currentUserSale: any) {user_metadata: { first_name, last_name },});- if (!data?.user || userError) {+ if (userError) {console.error(`Error inviting user: user_error=${userError}`);return createErrorResponse(userError.status, (userError as Error).message, {code: userError.code,});}+ if (!data?.user) {+ console.error("Error inviting user: undefined user");+ return createErrorResponse(500, "Internal Server Error");+ }+const { error: emailError } =await supabaseAdmin.auth.admin.inviteUserByEmail(email);- if (!data?.user || emailError) {+ if (emailError) {console.error(`Error inviting user, email_error=${emailError}`);return createErrorResponse(500, "Failed to send invitation mail");}