Sometimes your guests will forget their passwords and you want to give them a way to get a new one easily in your portal.

This article will show you make a request to our API to trigger the expedition of a mail or SMS to your guest containing the new password.

To start you'll have to get context from where your user connects. For this, we provide you with a simple way to do it. Just include this shortcode in your template:

{CONFIG_JSON}

This will be parsed and modified to a JSON string when uploading your portal on the admin console.
Inside will be the company hash of the location hosting your portal.
With this information you can make the HTTP request to our API. Here's an example with Javascript:

var input = loginInput.value

var configJSON = {CONFIG_JSON};

var url = 'https://login.cloudi-fi.net/api/2/register/password?ch=' + configJSON["c_hash"] + '&input=' + input;

Let's look at this step by step:

var input = loginInput.value

First, we store our user login in a variable. For the sake of the example, we didn't include any HTML reference. It is usually retrieved from a form on your portal.

var configJSON = {CONFIG_JSON};

This line will be transformed when you upload your portal to a JSON string containing information about the context of the location where this portal is used.

var configJSON = {"c_hash":"47dp0a24e785026a8n8c013j56u45k9"};

Here you can see a reduced sample of the modified string containing your company hash that will be required when making the HTTP request to the API.

var url = 'https://login.cloudi-fi.net/api/2/register/password?ch=' + configJSON["c_hash"] + '&input=' + input;

We concatenate all our previous elements into the URL of the API with all the required parameters: company hash and input which in this case is the user mail.

Then the guest will receive his new password by mail or SMS.

Did this answer your question?