コード例 #1
0
ファイル: index.php プロジェクト: brbrown59/bread-basket
require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
//composer for Swiftmailer
require_once dirname(dirname(dirname(dirname(__DIR__)))) . "/vendor/autoload.php";
//verify the xsrf challenge
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}
// prepare default error message
$reply = new stdClass();
$reply->status = 200;
$reply->data = null;
try {
    //grab the mySQL connection
    $pdo = connectToEncryptedMySQL("/etc/apache2/capstone-mysql/breadbasket.ini");
    $volEmailActivation = filter_input(INPUT_GET, "emailActivation", FILTER_SANITIZE_STRING);
    $volunteer = Volunteer::getVolunteerByVolEmailActivation($pdo, $volEmailActivation);
    if (empty($volunteer) === true) {
        throw new InvalidArgumentException("Activation code has been activated or does not exist", 404);
    } else {
        $volunteer->setVolEmailActivation(null);
        $volunteer->update($pdo);
    }
    $reply->data = "Congratulations, your account has been activated!";
    //redirect them somewhere
    // building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account.
    $basePath = $_SERVER["SCRIPT_NAME"];
    //iterate to get to the right path (gotta be a cleaner way to do this...)
    for ($i = 0; $i < 3; $i++) {
        $lastSlash = strrpos($basePath, "/");
        $basePath = substr($basePath, 0, $lastSlash);
    }
コード例 #2
0
 /**
  * test grabbing a volunteer by Email Activation
  */
 public function testGetVolunteerByVolEmailActivation()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("volunteer");
     // create a new Volunteer and insert to into mySQL
     $volunteer = new Volunteer(null, $this->organization->getOrgId(), $this->VALID_EMAIL, $this->VALID_EMAIL_ACTIVATION, $this->VALID_FIRST_NAME, $this->VALID_HASH, $this->VALID_VOL_IS_ADMIN, $this->VALID_LAST_NAME, $this->VALID_PHONE, $this->VALID_SALT);
     $volunteer->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoVolunteer = Volunteer::getVolunteerByVolEmailActivation($this->getPDO(), $volunteer->getVolEmailActivation());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("volunteer"));
     $this->assertSame($pdoVolunteer->getOrgId(), $this->organization->getOrgId());
     $this->assertSame($pdoVolunteer->getVolEmail(), $this->VALID_EMAIL);
     $this->assertSame($pdoVolunteer->getVolEmailActivation(), $this->VALID_EMAIL_ACTIVATION);
     $this->assertSame($pdoVolunteer->getVolFirstName(), $this->VALID_FIRST_NAME);
     $this->assertSame($pdoVolunteer->getVolHash(), $this->VALID_HASH);
     $this->assertSame($pdoVolunteer->getVolIsAdmin(), $this->VALID_VOL_IS_ADMIN);
     $this->assertSame($pdoVolunteer->getVolLastName(), $this->VALID_LAST_NAME);
     $this->assertSame($pdoVolunteer->getVolPhone(), $this->VALID_PHONE);
     $this->assertSame($pdoVolunteer->getVolSalt(), $this->VALID_SALT);
 }