Script Examples

Feature Introduction

# Creating a Restricted Email Whitelist

This module guides you on how to create an event for a restricted email whitelist.

function(context){   
  var email = context.user.email;
  new Log(context).debug(email);
  if (!email.endsWith("@example.com")) {
  return new Result("Email must end with example.com");
  }
}
1
2
3
4
5
6
7

This event is used to check whether the email domain configured when adding a new user is example.com. If not, it returns a Return object and the process ends; if it is, the process ends normally and proceeds to the next script.

# Creating a Webhook Notification Event

This module guides you on creating an event that sends a WebHook notification when a user's email changes.

function(context){   
  if (context.user.email !== context.oldUser.email) {
  var webhook = env.APP_WEBHOOK;
  var header = {"Authorization":"Basic " + env.APP_TOKEN};
  var body = context.user;
  HttpClient.post(webhook, body, header);
  }
}
1
2
3
4
5
6
7
8

This event is used to send a WebHook notification when a user's email changes. It is recommended that developers configure it to "Execute Asynchronously".