Custom Authentication

You can define your own custom functions to validate user input on button click. To achieve this add data-callback="{someFunction}" to the launch button. Then define your custom function in a JS file that accepts two parameters: onSuccess, onFailure.

Example

We have as an example the following HTML elements:

<input type="text" id="yomInput" placeholder="your name" autofocus>
<input type="password" id="password" placeholder="Enter password">
<button type="submit" data-callback="validatePassword" id="yomLaunch-1">start the experience</button>

In the following example function we perform simple front-end validation to match the data-callback="validatePassword"attribute defined in the yomLaunch-1 button:

function validatePassword(onSuccess, onFailure) {
    const passwordInput = document.getElementById('password');
    const enteredPassword = passwordInput.value;
    const hardcodedPassword = 'secure123';  // This is the hardcoded password

    if (enteredPassword === hardcodedPassword) {
        onSuccess();  // Call the success callback if the password is correct
    } else {
        onFailure();  // Call the failure callback if the password is incorrect
    }
}

Last updated