# Why are custom scripts required if using Auth0 datastore in my Auth0 connection

**URL:** <https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041>\
**Category:** Get Help\
**Tags:** regular-database-connections, connections\
**Created:** [December 6, 2024, 6:45pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041 "2024-12-06T18:45:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean8](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean8/32/59756_2.png) [@sean8](https://community.auth0.com/u/sean8)\
**Post date:** [December 6, 2024, 6:45pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/1 "2024-12-06T18:45:07Z")

</div>

As I understand it, custom scripts are not required when using an Auth0 provided data store within my Auth0 connection. However, when trying to remove the custom scripts in our dev instance using the Auth0 Terraform provider, login fails and there’s no log entires within the Monitoring Logs. This surprises me because when initially creating the resource there were no custom scripts and login worked in all three of our tenants (dev, staing, production). In fact, in two of our tenants (staging, and production) it’s working fine without them. However, when removing them from dev is where problems arise in our dev instance. I believe someone might have used the management UI to change a resource in Auth0 which led to the script creation, but we’re not sure which change would have created these scripts.

I also noticed some weird behavior, that if I change the script for “change\_password” to the string “blamo” (as opposed to a javascript function), then try to change the user’s password in the management portal, I get the following error: “Error! Sandbox Error: blamo is not defined”. This leads me to belive that custom scripts are in fact required, despite your Ask AI chat bot telling me they aren’t required. I’ve added screenshots to show this.

I’m confused about this and it’s causing us problems. Can you please clarify

1. What actions in the UI would lead to custom scripts being created for our Auth0 connection despite it only using an Auth0 provided data store
2. Why are these custom scripts unable to be deleted without breaking login, change password, and other functionality
3. Is it possible to delete the scripts without breaking login, change password and other functionality.

Thanks,  
Sean

 ![error message](https://global.discourse-cdn.com/auth0/original/3X/8/5/85a6055d74335b76d08a4f915a3980d7efb54af1.png)  
 ![terraform-plan](https://global.discourse-cdn.com/auth0/original/3X/6/9/694634feeb13c6bb7a408ec166dc0782c110112d.png)  
 ![terraform-code](https://global.discourse-cdn.com/auth0/original/3X/7/1/7113a177fe3582e769c5e94026a03b45fe6ccd21.png)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 9, 2024, 10:18pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/3 "2024-12-09T22:18:30Z")

</div>

Hi @sean8,

The custom scripts are only required to be implemented if you are using a [custom database connection](https://auth0.com/docs/authenticate/database-connections/custom-db/templates).

If you are using it as a regular database connection, then you need to disable the **Use my own database** option in your database settings.

In Terraform, you will need to include `enabled_database_customization = false` in your options object for your connection. (Reference: [Terraform Registry](https://registry.terraform.io/providers/auth0/auth0/latest/docs/resources/connection#enabled_database_customization-1))

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![sean8](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean8/32/59756_2.png) [@sean8](https://community.auth0.com/u/sean8)\
**Post date:** [December 9, 2024, 11:34pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/4 "2024-12-09T23:34:09Z")

</div>

Hi @rueben.tiow , Thanks for the reply.

- We’re not using a custom database connection
- I have `enabled_database_customization = false` in my terraform code
- Login fails if we set `custom_scripts = {}` in the terraform code
- Login fails unless `custom_scripts.login` is a valid javascript function

Do you have any other insight into why this problem unexpectedly started happening?

Thanks,  
Sean

 ![Screenshot 2024-12-09 at 3.32.13 PM](https://global.discourse-cdn.com/auth0/original/3X/e/2/e244fe14b1f680814f514ca27bffff324960e8b4.png)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 10, 2024, 11:14pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/5 "2024-12-10T23:14:28Z")

</div>

Hi @sean8,

Thanks for the update.

Firstly, I have just checked your dev tenants and noticed in the logs that there were successful login events (`s` log event type). Secondly, I verified that your settings are correctly configured with the custom database option disabled.

Based on your last bullet point about the login failing because it is asking for `custom_scripts.login` to be a valid javascript function, it seems like it’s expecting something like the following:

```auto
custom_scripts = {
      login = <<EOF
        function login(email, password, callback) {
            return callback(new Error(msg));
        }
      EOF
    }

```

If you have set the `custom_database_customizations = false`, then you might need to also omit the `custom_scripts = {}` code block to prevent any unwated issues arising from an undefined or empty custom script.

Let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![sean8](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean8/32/59756_2.png) [@sean8](https://community.auth0.com/u/sean8)\
**Post date:** [December 10, 2024, 11:47pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/6 "2024-12-10T23:47:18Z")

</div>

> [@rueben.tiow](#):
>
> firstly, I have just checked your dev tenants and noticed in the logs that there were successful login events (`s` log event type).

I had to re-add the `custom_scripts` after our dev tenant functionality (login, forgot\_password, etc.) was broken when setting `custom_scripts = {}`.

Here’s the order of operations we had while trying to understand and fix the problem:

1. Initial setup with Terraform, using `custom_scripts = {}` → login working
2. Custom scripts somehow (accidentally in the UI?) populated with JS scripts between steps 1 and 3 → login working
3. Setting `custom_scripts = {}` → login broken
4. Re-add valid functions, like the one you described, to `custom_scripts` → login working
5. Set `custom_scripts = {}`, or remove `custom_scripts = {}` → login broken,

This leads me to believe that `custom_scripts` needs to be populated with valid javascript functions in order for login to work, however, it was previously set to an empty object on multiple tenants (including this very dev tenant), which is where my confusion around this arises. The documentation also suggests this should be working, which makes me nervous since we’ll use the same module as dev in our production instance.

This leads me to the question: why is `custom_scripts` requiring valid JS functions with `custom_database_customizations = false` on this tenant when other tenants didn’t require this setting?

I hope that helps clarify what we’re experiencing, how we’ve narrowed down the issue, and why we’re confused about the configuration around `custom_scripts` and `custom_database_customizations`.

Thanks again,  
Sean

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 12, 2024, 6:05pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/7 "2024-12-12T18:05:58Z")

</div>

Hi @sean8,

Thanks for the update!

I’m glad the login is working now after including the default `custom_scripts`. This is also justified by the example from Terraform, which includes these scripts for a regular database connection.

It seems that the reason for requiring the empty scripts must have something to do with the way the it expects it to be non-empty to define the database connection correctly. This setting looks like it needs to be defined even if it’s unused.

Let us know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 26, 2024, 6:06pm UTC](https://community.auth0.com/t/why-are-custom-scripts-required-if-using-auth0-datastore-in-my-auth0-connection/158041/8 "2024-12-26T18:06:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
