Custom registration examples
The scripts below are executed by the OneWelcome Identity Platform during custom registration.
For variables that differ per environment, such as URLs, or contain sensitive data, such as passwords, use properties .
Init script
function execute(requestPayload) {
return {
status: 2000,
responsePayload: ""
};
}
Complete script
The complete script requires a user
object with an id
property defined to be returned. The amr
property is optional.
function execute(requestPayload) {
var userId = "userId_" + Date.now();
return {
status: 2000,
user: {
id: userId,
amr: ["mfa", "pwd"]
}
};
}
Backchannel communication script
function execute(requestPayload) {
var userId = requestPayload.userId;
var uniqueIdentifier = userId+"_"+Date.now();
CACHE.store(uniqueIdentifier, userId); //Another script could use CACHE.fetch(...) to retrieve the stored value
return {
status: 2000,
responsePayload: uniqueIdentifier
};
}
Status codes
When writing a custom script, these status code ranges should be used.
Status | Description |
---|---|
2xxx | Success |
4xxx | Failed, user can try again |
5xxx | Failed, cleanup actions should be triggered and user must start at beginning again |