Skip to content

Commit

Permalink
Notes on customizing rule callback
Browse files Browse the repository at this point in the history
  • Loading branch information
patkub committed Aug 3, 2024
1 parent 880e892 commit 1dcb851
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,20 @@ exports.onExecutePostLogin = async (event, api) => {
The following is an example on how to use a custom Rule callback. It adds the ability to handle redirects applied to context.

```javascript
const RuleToAction = require("auth0-rule-as-action");

/**
* The Rule
*/
function simpleRedirectRule(user, context, callback) {
context.redirect = {
url: "https://example.com/foo"
};
callback(null, user, context);
}

exports.onExecutePostLogin = async (event, api) => {
const rule = accessOnWeekdaysOnly;
const rule = simpleRedirectRule;

// Custom rule callback
const customRuleCallback = async (obj, newUser, newContext) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-rule-as-action",
"version": "0.3.2",
"version": "0.3.3",
"description": "Run an Auth0 Rule as an Action",
"author": "Patrick Kubiak <[email protected]>",
"main": "dist/RuleToAction.js",
Expand Down

0 comments on commit 1dcb851

Please sign in to comment.