Extension Installation Validator

The installation validator is triggered to validate the user before installing the extension. The validator is not configured by default. If the installation validator is not configured, users will be allowed to install the extension without validation. To configure the installation validator of an extension,

  • Open the extension preview page
  • Select the Handlers tab
  • Click Edit Code under the Installation Validator

The below shown attributes will be passed when an installation validator is executed: 

AttributeDescription
userDetails of the user who is installing the extension.
app_info

 Details of the extension being installed.

{"current_version":"1.5", "type": "install"}

Details of the extension being upgraded.

{"current_version":"1.5","existing_version":"1.3","type":"upgrade"}

Validation Success:

 If the installation validator is configured, the user will be allowed to install the extension only when the validator returns a response 200. 

Validation Failure:

The installation validator can be programmed to render a response message to the user when the extension validation fails. The message can have the following attributes:

  • title - Attribute of the type String, can be used to set a title for your extension installation failure. 
  • message - Attribute of the type String, can be used to show the extension installation error message.
  • note - Attribute of the type Array, can be used to show the user a list of reasons why the installation was not successful. 
  • footer - Attribute of the type String, can be used to give the user any extra information. For example, the support email ID can be given in the footer. 

Sample message when extension validation fails

Sample Code Snippet


response = Map();
success = true;
if(success)
{
	response.put("status","200");
}
else
{
	response.put("status","500");
	response.put("title","Uh-oh!");
	response.put("message","We're sorry! The extension installation failed.");
	note = list();
	note.add("Installation failure might be due to the following reasons:");
	note.add("1. Your account is not in the premium plan.");
	note.add("2. You have not configured the webhook properly.");
	response.put("note",note);
	response.put("footer","Contact support@yourdomain.com for any related help / support.");
}
return response;

 

Note:

The above code snippet will return a success response by default.

User Scenario

Let us consider an extension integrating GitLab and Cliq. The installation validator is configured to verify and allow only GitLab project admins to install the extension in Cliq. If a user who is not an admin in the GitLab Project, tries to install the extension in Cliq, the validator will fail and throw an error message. Take a look at the code snippet, given below. 

Note:

To use this code snippet, create a custom connection for GitLab in Cliq. Refer this page on how to create a custom connection in Cliq. 

 



response = Map();
git_projects = invokeurl
[
	url :"https://gitlab.com/api/v4/user"
	type :GET
	connection:"ENTER THE CONNECTION NAME"
];
id = git_projects.get("id");
if(!id == null)
{
	response.put("status","200");
        response.put("title","Awesome!");
	response.put("message","Extension installed successfully!");
        
}
else
{
	response.put("status","500");
	response.put("title","Uh-oh!");
	response.put("message","We're sorry! The extension installation failed.");
	note = list();
	note.add("Installation failure might be due to the following reasons:");
	note.add("1. Your account is not in the premium plan.");
	note.add("2. You have not configured the webhook properly.");
	response.put("note",note);
	response.put("footer","Contact support@yourdomain.com for any related help / support.");
}
return response;