/** * @covers User::getScope */ public function testGetScope() { $scope = $this->object->getScope(); $this->assertContains('user', $scope, 'Scope should contain "user"'); $this->assertContains('admin', $scope, 'Scope should contain "admin"'); }
/** * Check the if the user have a correct authentication and authorization. * * @param string $requiredScope Required user scope for processing the API * * @return bool Return if user has the required scope or not */ public function checkScope($requiredScope) { if (is_int($this->requesterId)) { require_once $_SERVER['DOCUMENT_ROOT'] . '/server/lib/User.php'; $requester = new User($this->requesterId); $scope = $requester->getScope(); //return if required scope is found in user scope return in_array($requiredScope, $scope); } //requester is not identified, return false return false; }