/**
 * Allows extension to modify what preferences will be saved
 */
function onPreferencesFormPreSave($formData, $form, $user, &$result)
{
    $errorMsg = '';
    //the user has not paired Mediawiki account with Latch
    if (!dbHelper::isPaired()) {
        $oneTimePassword = $formData["formUnpairedTextbox"];
        //get the OTP writen by the user in the textbox form
        LatchController::doPair($oneTimePassword);
    } else {
        if (dbHelper::isPaired() && isset($_POST["wpformPairedButton"])) {
            $responseUnpair = LatchController::doUnpair();
            if ($responseUnpair == -1) {
                $errorMsg = "Error durante proceso de despareado, por favor vuelve a intentarlo.";
                if ($errorMsg != '') {
                    return $errorMsg;
                }
            }
        }
    }
    return true;
    // Required return value of a hook function.
}