You can choose to let your users register themselves with an extra email verification step. Here is how it looks like from the user perspective:

This is the portal landing page where the user can choose email registration.

After filling the form the user can request a password that will be sent to his email.
Behind the scenes, when clicking the button an API call will be made to generate the credentials for this user and send an email containing the password.

Then by going back and choosing the login button he can fill in the form with his email and the supplied password.

When uploading the portal, it will be parsed to look for an HTML element with the source property set to the registering method. It must be in a form HTML element. The form element itself can have no properties, they will be added automatically when uploading the template. It is advised to do it in a hidden input element like this:

<input type="hidden" name="source" value="self">

Integrate the email registration in your portal template

To let your users register with email, 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.
Inside will be the company hash of the location hosting your portal.
With this information you can make an HTTP request to our API to register your user. Here's an example with Javascript:

var user = {
  mail:'john.doe@mail.com',
  firstname:'John',
  lastname:'Doe'
};

var registration = 'self';

var configJSON = {CONFIG_JSON};

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

$.get(url,function(data){
  console.log(data);
});

Let's dive into this step by step:

var user = {
  mail:'john.doe@mail.com',
  firstname:'John',
  lastname:'Doe'
};

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

var registration = 'self';

We declare a variable with the registration method you want for your portal, in this case 'self' means the user self-register and will receive his credentials on the email he provided.

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/'+ registration +'?ch='+ configJSON["c_hash"] +'&firstname='+ user.firstname +'&lastname='+ user.lastname +'&input='+ user.mail;

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

$.get(url,function(data){
  console.log(data);
});

Finally, we make the HTTP request, using the JQuery library get function here, and log the result to the console.

Did this answer your question?