Site URL Customisation
Overview
The SiteURL screen will remember the last submitted organization URL to make logging in easier. This is done by storing the submitted URL into AsyncStorage
when the form is submitted under the key @LAST_URL
, and then retrieving the value again when the SiteURL screen is next navigated to.
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.