Ejemplo n.º 1
0
 /**
  * test grabbing Access by content that does not exist
  */
 public function testGetInvalidAccessByAccessId()
 {
     //grab a user id that exceeds the maximum allowable profile id
     $access = Access::getAccessByAccessId($this->getPDO(), TimeCrunchersTest::INVALID_KEY);
     $this->assertNull($access);
 }
Ejemplo n.º 2
0
         }
     }
 }
 //if the session belongs to an admin, allow post, put and delete methods
 if (Access::isAdminLoggedIn() === true) {
     if ($method === "PUT" || $method === "POST") {
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         //make sure all fields are present, in order to fix database issues
         if (empty($requestObject->accessName) === true) {
             throw new InvalidArgumentException("accessName cannot be null", 405);
         }
         //perform put or post
         if ($method === "PUT") {
             $access = Access::getAccessByAccessId($pdo, $id);
             if ($access === null) {
                 throw new RuntimeException("access does not exist", 404);
             }
             $access = new Access($id, $requestObject->accessName);
             $access->update($pdo);
             $reply->message = "Access updated ok";
             //check to make sure a non-admin is only attempting to edit themselves
             //if not, take their temp access and throw an exception
             // use the example from Slack to determine admins
         } else {
             if ($method === "POST") {
                 $access = new Access(null, $requestObject->accessName);
                 $access->insert($pdo);
                 $reply->message = "Access created OK";
             }