Backendless Support
 

Creating Server-Side Business Logic for User Service API with Console

This topic reviews the process of creating an event handler for User Service APIs using Backendless console. 

The User Service APIs include: user registration, login, logout, user update, password recovery and retrieval of a user schema (a list of user properties and their types). 

A developer can build an event handler (or two event handlers - "before" and "after") for each of these operations.

To simplify the process of developing the event handlers, there is a code generator which is included into the Backendless developer console. The code generator can create all the required code for event handler, minus the actual business logic which is all that's left for a developer to add. 

For example, suppose a business logic must be triggered every time a user registers with an app . To create an event handler for that API:

  1. In the Backendless developer console, click the Business Logic icon.
  2. Select Users in the list of Event Handlers (the reason you need to select "Users" is because we are adding an event handler for one of the User Service APIs).
  3. Click the Add Event Handler button.
  4. Select Register from the Event drop-down. The screen should look as shown below: 

As it is shown, the user interface enables to pick an event for which it is necessary to create an event handler. It is also possible to select the "timing" of the handler by selecting the "Before" or "After" option. Finally, a developer can choose the event handler to be executed either synchronously or asynchronously. The latter means the API processing chain will not wait for the handler to complete its execution.

When you click Save, Backendless Console automatically generates the code for the event handler: 

Similarly to Timers, a developer can download the code to add the own business logic. 

Is article helpful?