Skip to content

Commit

Permalink
Merge pull request #410 from jjrom/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jjrom authored May 13, 2024
2 parents 4dbd987 + 3999c08 commit edb93f5
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/resto/core/RestoUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,10 @@ public function hasRightsTo($action, $params = array())
// Only owner of feature can do this
case RestoUser::DELETE_FEATURE:
case RestoUser::UPDATE_FEATURE:
if ( !isset($feature) ) {
if ( !isset($params['feature']) ) {
return false;
}
$featureArray = $feature->toArray();
$featureArray = $params['feature']->toArray();
return $rights[$action] && isset($featureArray['properties']['owner']) && $featureArray['properties']['owner'] !== $this->profile['id'];

default:
Expand Down
8 changes: 4 additions & 4 deletions app/resto/core/addons/STACCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function addCatalog($params, $body)
* Update catalog as a facet entry
*
* @OA\Put(
* path="/catalogs/{catalogId}",
* path="/catalogs/catalogs/{catalogId}",
* summary="Update catalog",
* description="Update catalog as a facet entry",
* tags={"STAC"},
Expand Down Expand Up @@ -231,7 +231,7 @@ public function updateCatalog($params, $body)
* Delete catalog as a facet entry
*
* @OA\Delete(
* path="/catalogs/{catalogId}",
* path="/catalogs/catalogs/{catalogId}",
* summary="Delete catalog",
* description="Delete catalog as a facet entry - update feature keywords accordingly",
* tags={"STAC"},
Expand Down Expand Up @@ -368,12 +368,12 @@ private function storeCatalogAsFacet($catalog, $parentId)
$catalog['id'] = substr($catalog['id'], strlen($this->prefix));
}

$parentId = isset($parentId) ? (str_starts_with($parentId, $this->prefix) ? $parentId : $this->prefix . $parentId) : null;
$parentId = isset($parentId) ? (str_starts_with($parentId, $this->prefix) ? $parentId : $this->prefix . $parentId) : 'root';

/*
* Catalog already exist
*/
if ( $this->catalogExists($this->prefix . $catalog['id'], $parentId ?? 'root', '*') ) {
if ( $this->catalogExists($this->prefix . $catalog['id'], $parentId, '*') ) {
return RestoLogUtil::httpError(409, 'Catalog ' . $catalog['id'] . ' already exist');
}

Expand Down
103 changes: 87 additions & 16 deletions docs/api/resto-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@
<ul class="toc-list-h1">

<li>
<a href="#welcome-to-resto" class="toc-h1 toc-link" data-title="Welcome to resto v8.0.9">Welcome to resto v8.0.9</a>
<a href="#welcome-to-resto" class="toc-h1 toc-link" data-title="Welcome to resto v8.0.10">Welcome to resto v8.0.10</a>

</li>

Expand Down Expand Up @@ -1623,6 +1623,11 @@

</li>

<li>
<a href="#usersapi--getmyprofile" class="toc-h2 toc-link" data-title="UsersAPI::getMyProfile">UsersAPI::getMyProfile</a>

</li>

<li>
<a href="#usersapi--getuserprofile" class="toc-h2 toc-link" data-title="UsersAPI::getUserProfile">UsersAPI::getUserProfile</a>

Expand Down Expand Up @@ -1951,7 +1956,7 @@
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<h1 id="welcome-to-resto">Welcome to resto v8.0.9</h1>
<h1 id="welcome-to-resto">Welcome to resto v8.0.10</h1>
<blockquote>
<p>Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.</p>
</blockquote>
Expand Down Expand Up @@ -3940,7 +3945,7 @@ <h3 id="stac--search-parameters">Parameters</h3>
<td>query</td>
<td>integer</td>
<td>false</td>
<td>Limit search to owner's features</td>
<td>Limit search to owner's features (i.e. resto user identifier as bigint)</td>
</tr>
<tr>
<td>likes</td>
Expand Down Expand Up @@ -4444,7 +4449,7 @@ <h3 id="featuresapi--getfeaturesincollection-parameters">Parameters</h3>
<td>query</td>
<td>integer</td>
<td>false</td>
<td>Limit search to owner's features</td>
<td>Limit search to owner's features (i.e. resto user identifier as bigint)</td>
</tr>
<tr>
<td>likes</td>
Expand Down Expand Up @@ -5932,10 +5937,10 @@ <h3 id="groupapi--getusergroups-responseschema">Response Schema</h3>
</tr>
<tr>
<td>»» owner</td>
<td>string</td>
<td>integer</td>
<td>true</td>
<td>none</td>
<td>Owner of the group (i.e. user unique identifier)</td>
<td>Owner of the group (i.e. resto user identifier as bigint)</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -6422,6 +6427,72 @@ <h3 id="usersapi--createuser-responseschema">Response Schema</h3>
<aside class="success">
This operation does not require authentication
</aside>
<h2 id="usersapi--getmyprofile">UsersAPI::getMyProfile</h2>
<p><a id="opIdUsersAPI::getMyProfile"></a></p>
<blockquote>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X GET http://127.0.0.1:5252/user \
-H <span class="hljs-string">'Accept: application/json'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>

</code></pre>
<p><code>GET /user</code></p>
<p><em>Get my profile</em></p>
<blockquote>
<p>Example responses</p>
</blockquote>
<blockquote>
<p>200 Response</p>
</blockquote>
<pre class="highlight tab tab-json"><code>{
<span class="hljs-attr">"id"</span>: <span class="hljs-string">"1356771884787565573"</span>,
<span class="hljs-attr">"picture"</span>: <span class="hljs-string">"https://robohash.org/d0e907f8b6f4ee74cd4c38a515e2a4de?gravatar=hashed&amp;bgset=any&amp;size=400x400"</span>,
<span class="hljs-attr">"groups"</span>: [
<span class="hljs-string">"1"</span>
],
<span class="hljs-attr">"name"</span>: <span class="hljs-string">"jrom"</span>,
<span class="hljs-attr">"followers"</span>: <span class="hljs-number">185</span>,
<span class="hljs-attr">"followings"</span>: <span class="hljs-number">144</span>,
<span class="hljs-attr">"firstname"</span>: <span class="hljs-string">"Jérôme"</span>,
<span class="hljs-attr">"lastname"</span>: <span class="hljs-string">"Gasperi"</span>,
<span class="hljs-attr">"bio"</span>: <span class="hljs-string">"Working on new features for the next major release of SnapPlanet"</span>,
<span class="hljs-attr">"registrationdate"</span>: <span class="hljs-string">"2016-10-08T22:50:34.187217Z"</span>,
<span class="hljs-attr">"topics"</span>: <span class="hljs-string">"earth,fires,geology,glaciology,volcanism"</span>,
<span class="hljs-attr">"followed"</span>: <span class="hljs-literal">false</span>,
<span class="hljs-attr">"followme"</span>: <span class="hljs-literal">false</span>
}
</code></pre>
<h3 id="usersapi--getmyprofile-responses">Responses</h3>
<table>
<thead>
<tr>
<th>Status</th>
<th>Meaning</th>
<th>Description</th>
<th>Schema</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td><a href="https://tools.ietf.org/html/rfc7231#section-6.3.1">OK</a></td>
<td>User profile</td>
<td><a href="#schemauserdisplayprofile">UserDisplayProfile</a></td>
</tr>
<tr>
<td>401</td>
<td><a href="https://tools.ietf.org/html/rfc7235#section-3.1">Unauthorized</a></td>
<td>Unauthorized</td>
<td><a href="#schemaunauthorizederror">UnauthorizedError</a></td>
</tr>
</tbody>
</table>
<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
basicAuth & bearerAuth & queryAuth
</aside>
<h2 id="usersapi--getuserprofile">UsersAPI::getUserProfile</h2>
<p><a id="opIdUsersAPI::getUserProfile"></a></p>
<blockquote>
Expand Down Expand Up @@ -7506,7 +7577,7 @@ <h3 id="stac--getchildren-responseschema">Response Schema</h3>
<td>string</td>
<td>false</td>
<td>none</td>
<td>Owner of the feature i.e. user that created it</td>
<td>Owner of the feature (i.e. resto user identifier as bigint)</td>
</tr>
<tr>
<td>»»» status</td>
Expand Down Expand Up @@ -7627,13 +7698,13 @@ <h2 id="staccatalog--updatecatalog">STACCatalog::updateCatalog</h2>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X PUT http://127.0.0.1:5252/catalogs/{catalogId} \
curl -X PUT http://127.0.0.1:5252/catalogs/catalogs/{catalogId} \
-H <span class="hljs-string">'Content-Type: application/json'</span> \
-H <span class="hljs-string">'Accept: application/json'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>

</code></pre>
<p><code>PUT /catalogs/{catalogId}</code></p>
<p><code>PUT /catalogs/catalogs/{catalogId}</code></p>
<p><em>Update catalog</em></p>
<p>Update catalog as a facet entry</p>
<blockquote>
Expand Down Expand Up @@ -7786,12 +7857,12 @@ <h2 id="staccatalog--removecatalog">STACCatalog::removeCatalog</h2>
<p>Code samples</p>
</blockquote>
<pre class="highlight tab tab-shell"><code><span class="hljs-comment"># You can also use wget</span>
curl -X DELETE http://127.0.0.1:5252/catalogs/{catalogId} \
curl -X DELETE http://127.0.0.1:5252/catalogs/catalogs/{catalogId} \
-H <span class="hljs-string">'Accept: application/json'</span> \
-H <span class="hljs-string">'Authorization: Bearer {access-token}'</span>

</code></pre>
<p><code>DELETE /catalogs/{catalogId}</code></p>
<p><code>DELETE /catalogs/catalogs/{catalogId}</code></p>
<p><em>Delete catalog</em></p>
<p>Delete catalog as a facet entry - update feature keywords accordingly</p>
<h3 id="staccatalog--removecatalog-parameters">Parameters</h3>
Expand Down Expand Up @@ -8512,10 +8583,10 @@ <h3 id="groupapi--getgroups-responseschema">Response Schema</h3>
</tr>
<tr>
<td>»» owner</td>
<td>string</td>
<td>integer</td>
<td>true</td>
<td>none</td>
<td>Owner of the group (i.e. user unique identifier)</td>
<td>Owner of the group (i.e. resto user identifier as bigint)</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -11039,7 +11110,7 @@ <h3 id="properties">Properties</h3>
<td>string</td>
<td>false</td>
<td>none</td>
<td>Owner of the feature i.e. user that created it</td>
<td>Owner of the feature (i.e. resto user identifier as bigint)</td>
</tr>
<tr>
<td>» status</td>
Expand Down Expand Up @@ -12113,10 +12184,10 @@ <h3 id="properties">Properties</h3>
</tr>
<tr>
<td>owner</td>
<td>string</td>
<td>integer</td>
<td>true</td>
<td>none</td>
<td>Owner of the group (i.e. user unique identifier)</td>
<td>Owner of the group (i.e. resto user identifier as bigint)</td>
</tr>
</tbody>
</table>
Expand Down
52 changes: 45 additions & 7 deletions docs/api/resto-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"contact": {
"email": "jerome.gasperi@gmail.com"
},
"version": "8.0.9"
"version": "8.0.10"
},
"servers": [
{
Expand Down Expand Up @@ -466,7 +466,7 @@
{
"name": "owner",
"in": "query",
"description": "Limit search to owner's features",
"description": "Limit search to owner's features (i.e. resto user identifier as bigint)",
"required": false,
"style": "form",
"schema": {
Expand Down Expand Up @@ -708,7 +708,7 @@
}
}
},
"/catalogs/{catalogId}": {
"/catalogs/catalogs/{catalogId}": {
"put": {
"tags": [
"STAC"
Expand Down Expand Up @@ -2015,7 +2015,7 @@
{
"name": "owner",
"in": "query",
"description": "Limit search to owner's features",
"description": "Limit search to owner's features (i.e. resto user identifier as bigint)",
"required": false,
"style": "form",
"schema": {
Expand Down Expand Up @@ -4101,6 +4101,44 @@
}
}
},
"/user": {
"get": {
"tags": [
"User"
],
"summary": "Get my profile",
"operationId": "UsersAPI::getMyProfile",
"responses": {
"200": {
"description": "User profile",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserDisplayProfile"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UnauthorizedError"
}
}
}
}
},
"security": [
{
"basicAuth": [],
"bearerAuth": [],
"queryAuth": []
}
]
}
},
"/users/{userid}": {
"get": {
"tags": [
Expand Down Expand Up @@ -5234,7 +5272,7 @@
"type": "integer"
},
"owner": {
"description": "Owner of the feature i.e. user that created it",
"description": "Owner of the feature (i.e. resto user identifier as bigint)",
"type": "string"
},
"status": {
Expand Down Expand Up @@ -6065,8 +6103,8 @@
"type": "string"
},
"owner": {
"description": "Owner of the group (i.e. user unique identifier)",
"type": "string"
"description": "Owner of the group (i.e. resto user identifier as bigint)",
"type": "integer"
}
},
"type": "object",
Expand Down

0 comments on commit edb93f5

Please sign in to comment.