Create installation and navigate to created account

Create installation and navigate to created account

Method to be used where we would use a separate account to create a new erply account. And then we would like the user to navigate to the created account without showing the default erply login.

Note that there are multiple workflows this can be used for:

  1. Source account and created accounts are on the same erply domain.
  2. Source account is on custom domain and the created account will use the erply domain.

Source account and created accounts are on the same erply domain

Since both run on the same domain then it’s enough to just run erply createInstallation. The process there will automatically set the auth cookie for the created account to the browser and since we are on the same domain then browser will automatically use it when we navigate to the created account.

<form type="post">
    <input type="hidden" name="ErplyApi.Api.Post.createInstallation" value="createInstallation">

    <!-- Required form fields would be here -->
    <input type="text" name="ErplyApi.Api.PostParam.createInstallation.username"
           value="15">
    <input type="text" name="ErplyApi.Api.PostParam.createInstallation.password"
           value="15">
    
    <!-- Depending on what cluster the main account is the target url might need to be adjusted -->
    <input type="hidden" name="Form.Redirect" value="https://template-engine-eu10.erply.com/[[ .Data.ErplyApi.Api.Requests.createInstallation.Response.Get `records.0.clientCode` ]]/en/store">
</form>

Source account is on custom domain and the created account will use erply domain

Note

Available from goerp version 1.314.0

In cases where the main app is on a different custom domain. In these case we cannot set cross domain cookies. Instead, we can pass the session key in the query parameter, goerp will take care of the session creation itself.

<form type="post">
    <input type="hidden" name="ErplyApi.Api.Post.createInstallation" value="createInstallation">

    <!-- Required form fields would be here -->
    <input type="text" name="ErplyApi.Api.PostParam.createInstallation.username"
           value="15">
    <input type="text" name="ErplyApi.Api.PostParam.createInstallation.password"
           value="15">
    
    <!-- Depending on what cluster the main account is the target url might need to be adjusted -->
    <input type="hidden" name="Form.Redirect" value="https://template-engine-eu10.erply.com/[[ .Data.ErplyApi.Api.Requests.createInstallation.Response.Get `records.0.clientCode` ]]/en/store?authKey=[[ .Data.ErplyApi.Api.Requests.createInstallation.Response.Get `records.0.sessionKey` ]]">
</form>

By default, accounts do not have any goerp applications installed. If we need to navigate to a new application then we would need to set the application up to auto install.

Requirements:

  1. The application needs to be published to the clusters store.
  2. The application needs to be set as auto installed (request with a raji ticket).
Note

Also note that passing the key is only needed if we want to navigate the user to a bo user view. If the user is to be navigated to a public page view then there is no need to pass the auth key.