The first step to develop authorization is to create an appropriate form.
Authorization form
For authorization, you will need two input fields:
- Login (here, the login will be an email).
- Password.
Also, you will need a button that will perform authorization BP.
Business Process for authorization
Go to the button Workflow and create a new BP.
First, get the values from the input fields. To do this, use the InputEmail Get Properties and InputPassword Get Properties blocks. Be sure to specify the Component ID so that the BP understands from which fields to take the information.
The next step is to create the authorization itself. Use the Server Request POST /auth block. Pass the value fields from InputEmail Get Properties and InputPassword Get Properties to it.
Now divide the BP into two cases: when authorization was successful and when it failed. Use the If-Else block and pass the _success field from the Server Request POST /auth to it.
On the False output connector (if authorization is unsuccessful), we need to show the user that he was unable to log in. To do this, use the InputEmail Update Properties and InputPassword Update Properties blocks. Also, set the Component ID fields in them, and set the Validate Status to Error. In the Validate Message field, specify Email or password is incorrect.
We need to set the authorization token on the True output connector (if authorization is successful). It requires a Set Auth Token block, to which we will pass the token field from the Server Request POST /auth block.
Now, an authorization token will be added to all API requests of the user.
After installing the token, you can send the user to another page. Use the Navigate block, in which we set the Page field, for example, to the Home page.