Skip to content

Commit

Permalink
Fix(mail): Add debug log when creating a user and add documentation a…
Browse files Browse the repository at this point in the history
…bout email rate limit
  • Loading branch information
jonathanarnault committed Aug 9, 2024
1 parent 1ddf538 commit b298109
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion doc/supabase-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ If you want to customize the production templates, you can go to your project da

Supabase requires additional configuration to enable Atomic CRM's email features. Have a look at the the [email features documentation](./email-features.md) to learn more about their usage and the required setup.

Warning: Free quota for email features is very low. If you encounter problems when creating a user or reseting a password, you can increase the sending limit via a custom STMP server setup. Please refer to the [supabase documentation](https://supabase.com/docs/guides/auth/auth-smtp) if this is your case.

## Fequently Asked Questions

- I have a **Security Definer View** error in **Security Advisor**

You can ignore this error. This warning informs you that the `init_state` state view is public and can be called by everybody.
This view is required to test if your CRM has been setup correctly. This view has been configured to avoid data leak.
This view is required to test if your CRM has been setup correctly. This view has been configured to avoid data leak.
9 changes: 7 additions & 2 deletions supabase/functions/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ async function inviteUser(req: Request) {
const { error: emailError } =
await supabaseAdmin.auth.admin.inviteUserByEmail(email);

if (!data?.user || userError || emailError) {
console.error('Error inviting user:', userError);
if (!data?.user || userError) {
console.error(`Error inviting user: user_error=${userError}`);
return createErrorResponse(500, 'Internal Server Error');
}

if (!data?.user || userError || emailError) {
console.error(`Error inviting user, email_error=${emailError}`);
return createErrorResponse(500, 'Failed to send invitation mail');
}

try {
await updateSaleDisabled(data.user.id, disabled);
const sale = await updateSaleAdministrator(data.user.id, administrator);
Expand Down

0 comments on commit b298109

Please sign in to comment.