Example #1
0
        requestKeyAdd($curusr, $certid, $_POST["certid"], $temporary);
    } elseif ($_POST['action'] == 'changefactor') {
        $submittedfactors = intval($_POST['numfactors']);
        if ($submittedfactors < 1 || $submittedfactors > $numactivedevs) {
            die('Invalid number of factors ' . $submittedfactors);
        }
        //Marks that this cert supports changing factors to X
        //Changing number of factors requires multi-factor votes and agreement
        requestMFAchange($curusr, $certid, $submittedfactors);
    } elseif ($_POST['action'] == 'updateaddress') {
        if (!(isset($_POST['address']) and isset($_POST['city']) and isset($_POST['state']) and isset($_POST['postcode']) and isset($_POST['country']))) {
            die("Must fill out all fields!");
        }
        requestAddressChange(getCertId(), $curusr, $_POST['address'], $_POST['city'], $_POST['state'], $_POST['postcode'], $_POST['country']);
    } elseif ($_POST['action'] == 'canceladdress') {
        removeAddressVotes($curusr);
    }
    exit;
}
$title = 'Profile';
include 'header.php';
$addressChanges = getAllAddressVotes($curusr);
echo '<h1>My Profile</h1>
<p class="text">Make sure your profile has your current address. If you lose access to your account, you can have a reset code sent to your address.</p>
<form method="post" action="profile" onsubmit="return confirm(&apos;Are you sure you want to change your address settings?&apos;);">
<input type="hidden" name="action" value="updateaddress">
<table>
<tbody>
<tr><td>Username:</td><td>' . htmlspecialchars($curusr) . '</td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value="' . htmlspecialchars($userdetails['address']) . '">';
foreach ($addressChanges as $address) {
Example #2
0
function requestAddressChange($certid, $user, $address, $city, $state, $postcode, $country)
{
    $currentMF = getMinFactors($user);
    //If MFA is not enabled, just make the change
    if ($currentMF < 2) {
        changeUserAddress($user, $address, $city, $state, $postcode, $country);
    } elseif (getAddressVotes($certid, $user, $address, $city, $state, $postcode, $country) >= $currentMF - 1) {
        //This is our last required vote, make the change.
        changeUserAddress($user, $address, $city, $state, $postcode, $country);
        removeAddressVotes($user);
        //And delete votes
    } else {
        addAddressVote($certid, $user, $address, $city, $state, $postcode, $country);
    }
}