docs: custom db connections maintenance - #1638
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
…ons' into docs/ia-custom-database-connections
Summary
Errors per inputErrors in main/docs/authenticate/database-connections/custom-db/custom-database-connections-scripts.mdx
|
| "docs/authenticate/database-connections/custom-db/templates/verify", | ||
| "docs/authenticate/database-connections/custom-db/templates/change-email" | ||
| "docs/authenticate/database-connections/custom-db/templates/change-email", | ||
| "docs/authenticate/database-connections/custom-db/action-script-best-practices" |
There was a problem hiding this comment.
formatting, maybe 1 more +tab
| function login(userNameOrEmail, password, callback) { | ||
| const hashedPassword = hash(password); | ||
| const apiEndpoint = 'https://example.com/api/authenticate'; | ||
| const options = { | ||
| method: 'POST', | ||
| body: { | ||
| email: userNameOrEmail, | ||
| password: hashedPassword | ||
| } | ||
| }; | ||
|
|
||
| fetch(apiEndpoint, options) | ||
| .then((response) => { | ||
| if (!response.ok) { | ||
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | ||
| } | ||
|
|
||
| return response.json(); | ||
| }) | ||
| .then((response) => { | ||
| if (response.err) { | ||
| return callback(new Error(`Error authenticating user: ${err}`)); | ||
| } | ||
|
|
||
| let profile = { | ||
| email: response.profileData.email, | ||
| username: response.profileData.username | ||
| }; | ||
|
|
||
| return callback(null, profile); | ||
| }) | ||
| .catch((err) => { | ||
| return callback(new Error(`An error occurred: ${err}`)); | ||
| }); | ||
| } |
There was a problem hiding this comment.
| function login(userNameOrEmail, password, callback) { | |
| const hashedPassword = hash(password); | |
| const apiEndpoint = 'https://example.com/api/authenticate'; | |
| const options = { | |
| method: 'POST', | |
| body: { | |
| email: userNameOrEmail, | |
| password: hashedPassword | |
| } | |
| }; | |
| fetch(apiEndpoint, options) | |
| .then((response) => { | |
| if (!response.ok) { | |
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | |
| } | |
| return response.json(); | |
| }) | |
| .then((response) => { | |
| if (response.err) { | |
| return callback(new Error(`Error authenticating user: ${err}`)); | |
| } | |
| let profile = { | |
| email: response.profileData.email, | |
| username: response.profileData.username | |
| }; | |
| return callback(null, profile); | |
| }) | |
| .catch((err) => { | |
| return callback(new Error(`An error occurred: ${err}`)); | |
| }); | |
| } | |
| async function login(userNameOrEmail, password, callback) { | |
| try { | |
| const apiEndpoint = 'https://example.com/api/authenticate'; | |
| const options = { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ | |
| email: userNameOrEmail, | |
| password: password // Send plaintext over HTTPS; API verifies it | |
| }) | |
| }; | |
| const response = await fetch(apiEndpoint, options); | |
| if (!response.ok) { | |
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | |
| } | |
| const result = await response.json(); | |
| if (result.err) { | |
| return callback(new Error(`Error authenticating user: ${result.err}`)); | |
| } | |
| const profile = { | |
| email: result.profileData.email, | |
| username: result.profileData.username | |
| }; | |
| return callback(null, profile); | |
| } catch (err) { | |
| return callback(err); | |
| } | |
| } |
| async function login(userNameOrEmail, password, callback) { | ||
| const hashedPassword = hash(password); | ||
| const apiEndpoint = 'https://example.com/api/authenticate'; | ||
| const options = { | ||
| method: 'POST', | ||
| body: { | ||
| email: userNameOrEmail, | ||
| password: hashedPassword | ||
| } | ||
| }; | ||
|
|
||
| const response = await fetch(apiEndpoint, options); | ||
|
|
||
| if (!response.ok) { | ||
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | ||
| } | ||
|
|
||
| const result = response.json(); | ||
|
|
||
| if (result.err) { | ||
| return callback(new Error(`Error authenticating user: ${err}`)); | ||
| } | ||
|
|
||
| let profile = { | ||
| email: response.profileData.email, | ||
| username: response.profileData.username | ||
| }; | ||
|
|
||
| return callback(null, profile); | ||
| } |
There was a problem hiding this comment.
| async function login(userNameOrEmail, password, callback) { | |
| const hashedPassword = hash(password); | |
| const apiEndpoint = 'https://example.com/api/authenticate'; | |
| const options = { | |
| method: 'POST', | |
| body: { | |
| email: userNameOrEmail, | |
| password: hashedPassword | |
| } | |
| }; | |
| const response = await fetch(apiEndpoint, options); | |
| if (!response.ok) { | |
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | |
| } | |
| const result = response.json(); | |
| if (result.err) { | |
| return callback(new Error(`Error authenticating user: ${err}`)); | |
| } | |
| let profile = { | |
| email: response.profileData.email, | |
| username: response.profileData.username | |
| }; | |
| return callback(null, profile); | |
| } | |
| ⏺ async function login(userNameOrEmail, password, callback) { | |
| try { | |
| const apiEndpoint = 'https://example.com/api/authenticate'; | |
| const options = { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ | |
| email: userNameOrEmail, | |
| password: password | |
| }) | |
| }; | |
| const response = await fetch(apiEndpoint, options); | |
| if (!response.ok) { | |
| return callback(new Error(`HTTP error! Status: ${response.status}`)); | |
| } | |
| const result = await response.json(); | |
| if (result.err) { | |
| return callback(new Error(`Error authenticating user: ${result.err}`)); | |
| } | |
| const profile = { | |
| email: result.profileData.email, | |
| username: result.profileData.username | |
| }; | |
| return callback(null, profile); | |
| } catch (err) { | |
| return callback(err); | |
| } | |
| } |
|
|
||
| You can use the `global` object to define information or functions used across all action scripts that run in the container instance or cache expensive resources, like storing an <Tooltip tip="Access Token: Authorization credential, in the form of an opaque string or JWT, used to access an API." cta="View Glossary" href="/docs/glossary?term=Access+Token">Access Token</Tooltip> for a third-party (logging) API or your own API defined in Auth0 and obtained via the [Client Credentials Flow](/docs/get-started/authentication-and-authorization-flow/client-credentials-flow). | ||
|
|
||
| <Warning> |
There was a problem hiding this comment.
| <Warning> | |
| <Callout icon="file-lines" color="#0EA5E9" iconType="regular"> |
|
|
||
| <Warning> | ||
| Do not store user-specific information the `global` object. Because there is no container affinity for action script execution in Auth0, action scripts may execute in any running container instance or in a new container instance added to the pool. | ||
| </Warning> |
There was a problem hiding this comment.
| </Warning> | |
| </Callout> |
| 5. Under the **Machine-to-Machine Applications** tab, use the toggle to authorize your test application. | ||
|
|
||
| 7. Select the drop-down menu to enable the following Auth0 Management API scopes: |
|
|
||
| The Change Email script implements the defined function when a user's email address or their email address verification status changes. We recommend naming this function `changeEmail`. | ||
|
|
||
| The script is only used in a [legacy authentication scenario](/docs/authenticate/database-connections/custom-db/overview-custom-db-connections), and is required if you want to update a user's email address (and/or email address verification status) in Auth0 and your external database in the same operation. |
There was a problem hiding this comment.
[nit] Should we clean this up now that it's redirecting?
| ### SQL Server | ||
|
|
||
| ```javascript lines expandable | ||
| ```javascript SQL Sever lines expandable |
There was a problem hiding this comment.
| ```javascript SQL Sever lines expandable | |
| ```javascript SQL Server lines expandable |
| callback(null, true); | ||
| ``` | ||
|
|
||
| <Warning> |
There was a problem hiding this comment.
| <Warning> | |
| <Callout icon="file-lines" color="#0EA5E9" iconType="regular"> |
|
|
||
| To update the `email_verified` attribute in the user's Auth0 profile, you must include the `email_verified` attribute and its value in the user profile object returned in the [Login](/docs/authenticate/database-connections/custom-db/templates/login) and [Get User](/docs/authenticate/database-connections/custom-db/templates/get-user) scripts. | ||
|
|
||
| </Warning> |
There was a problem hiding this comment.
| </Warning> | |
| </Callout> |
Description
two major bits of maintenance work:
massively reduces repeated information about custom dbs and action scripts
specifically, takes info across like nine pages on 1) what custom dbs are, 2) what action scripts are, and 3) recommendations for action scripts and organizes them onto 1) the existing custom db landing page, 2) the existing action scripts landing page, and 3) a singular new best practices page.
this results in removing six pages (
anatomy.mdx,connection-security.mdx,environment.mdx,execution.mdx,overview-custom-db-connections.mdx, andtemplates.mdx).create db connections article rewritten
two smaller changes:
action script pages now use
CodeGroups for samples and no longer have extraneous "example" headerstest custom db connections edited (mostly just to use tabs) but content untested and largely unchanged; do not evaluate for accuracy
Checklist
CONTRIBUTING.md.