Site URL customisation

Overview

The SiteURL screen will remember the last submitted organisation URL to make it faster and more convenient to log in. This is done by storing the submitted URL in AsyncStorage when the form is submitted under the @LAST_URL key, and then retrieving the value again when the SiteURL screen is next visited.

Customisations

This enhancement is enabled by default. Any modifications to how the feature works can be done in the src/totara/auth/manual/SiteUrl.tsx and src/totara/auth/manual/SiteUrlHook.ts files. Below are some examples of how you may want to customise how it works.

Hard-coding the URL to skip the SiteURL screen

In the SiteUrl.tsx file there is an onSubmit function which is returned by the useSiteUrl hook, which is how the URL is submitted to proceed to the next page. This can be called when the page mounts with a hard-coded URL to automatically proceed to the login screen.

Allowing choice of multiple URLs

Data stored in AsyncStorage are stored as strings. To store multiple URLs for the user to select from, instead of storing a single string into AsyncStorage, an array of URLs could be JSON.stringify-ed and then stored. Then when reading the value, the JSON can be parsed and the resulting array of strings could be presented in a dropdown-like UI.

To make a start on this, look for the addToSavedURLs function in the SiteUrlHook.ts file where the submitted URL is saved, as well as the getInitialURL function in SiteUrl.tsx where the URL is retrieved.