@whippsp/auth0-helper 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Auth0Helper.js +20 -20
- package/package.json +1 -1
package/Auth0Helper.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// Auth0Helper.js
|
|
2
|
+
module.exports = function (logic) {
|
|
3
|
+
// This is the actual function Auth0 will execute
|
|
4
|
+
return async (event, api) => {
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
6
|
+
// 1. Automatic Skip Logic:
|
|
7
|
+
// If a previous action set the flag, we stop here and don't even run the user's logic.
|
|
8
|
+
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
9
|
+
console.log("Auth0Helper: Skipping this action (flag detected).");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
// 2. Method Injection:
|
|
14
|
+
// We attach the helper directly to the api object instance for this execution.
|
|
15
|
+
api.skipRemaining = function() {
|
|
16
|
+
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
17
|
+
console.log("Auth0Helper: skipRemaining flag set.");
|
|
18
|
+
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
20
|
+
// 3. Execute User Logic:
|
|
21
|
+
// We pass the event and the enhanced api back to your function.
|
|
22
|
+
return await logic(event, api);
|
|
23
|
+
};
|
|
24
24
|
};
|