Ejemplo n.º 1
0
 }
 if (empty($requestObject->orgState) === true) {
     throw new InvalidArgumentException("organization state cannot be empty", 405);
 }
 if (empty($requestObject->orgType) === true) {
     throw new InvalidArgumentException("organization type cannot be empty", 405);
 }
 if (empty($requestObject->orgZip) === true) {
     throw new InvalidArgumentException("organization zip code cannot be empty", 405);
 }
 if (empty($requestObject->password) === true) {
     throw new InvalidArgumentException("password cannot be empty", 405);
 }
 // sanitize the email & search by volEmail
 $volEmail = filter_var($requestObject->volEmail, FILTER_SANITIZE_EMAIL);
 $volunteer = Volunteer::getVolunteerByVolEmail($pdo, $volEmail);
 if ($volunteer !== null) {
     throw new RuntimeException("This email already has an account", 422);
 }
 // create a new salt and email activation
 $volSalt = bin2hex(openssl_random_pseudo_bytes(32));
 $volEmailActivation = bin2hex(openssl_random_pseudo_bytes(8));
 // create the hash
 $volHash = hash_pbkdf2("sha512", $requestObject->password, $volSalt, 262144, 128);
 //create a new organization and insert into mySQL
 $organization = new Organization(null, $requestObject->orgAddress1, $requestObject->orgAddress2, $requestObject->orgCity, $requestObject->orgDescription, $requestObject->orgHours, $requestObject->orgName, $requestObject->orgPhone, $requestObject->orgState, $requestObject->orgType, $requestObject->orgZip);
 $organization->insert($pdo);
 $reply->message = "New organization has been created";
 //create a new Volunteer and insert into mySQL
 $volunteer = new Volunteer(null, $organization->getOrgId(), $requestObject->volEmail, $volEmailActivation, $requestObject->volFirstName, $volHash, true, $requestObject->volLastName, $requestObject->volPhone, $volSalt);
 $volunteer->insert($pdo);
Ejemplo n.º 2
0
 /**
  * test grabbing a volunteer by an email that does not exist
  */
 public function testGetInvalidVolunteerByVolEmail()
 {
     //grab an email that does not exist
     $volunteer = Volunteer::getVolunteerByVolEmail($this->getPDO(), "*****@*****.**");
     $this->assertNull($volunteer);
 }