mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 10:14:39 +00:00
Added an API endpoint to get the authenticated user (closes #1165)
This commit is contained in:
@@ -204,6 +204,7 @@
|
|||||||
- New endpoint `/stock/shoppinglist/add-overdue-products` to add all currently in-stock but overdue products to a shopping list (thanks @m-byte)
|
- New endpoint `/stock/shoppinglist/add-overdue-products` to add all currently in-stock but overdue products to a shopping list (thanks @m-byte)
|
||||||
- New endpoint `/stock/shoppinglist/add-expired-products` to add all currently in-stock but expired products to a shopping list
|
- New endpoint `/stock/shoppinglist/add-expired-products` to add all currently in-stock but expired products to a shopping list
|
||||||
- New endpoints GET/POST/PUT `/users/{userId}/permissions` for the new user permissions feature mentioned above
|
- New endpoints GET/POST/PUT `/users/{userId}/permissions` for the new user permissions feature mentioned above
|
||||||
|
- New endpoint '/user` to get the currently authenticated user
|
||||||
- The stock journal (entity `stock_log`) is now also available via the endpoint `/objects/{entity}` (=> `/objects/stock_log`)
|
- The stock journal (entity `stock_log`) is now also available via the endpoint `/objects/{entity}` (=> `/objects/stock_log`)
|
||||||
- Performance improvements of the `/stock/products/*` endpoints (thanks @fipwmaqzufheoxq92ebc)
|
- Performance improvements of the `/stock/products/*` endpoints (thanks @fipwmaqzufheoxq92ebc)
|
||||||
- The endpoint `/stock/products/{productId}/locations` now also has an optional query parameter `include_sub_products` to optionally also return locations of sub products of the given product
|
- The endpoint `/stock/products/{productId}/locations` now also has an optional query parameter `include_sub_products` to optionally also return locations of sub products of the given product
|
||||||
|
@@ -126,6 +126,18 @@ class UsersApiController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function CurrentUser(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return $this->ApiResponse($response, $this->getUsersService()->GetUsersAsDto()->where('id', GROCY_USER_ID));
|
||||||
|
}
|
||||||
|
catch (\Exception $ex)
|
||||||
|
{
|
||||||
|
return $this->GenericErrorResponse($response, $ex->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function ListPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function ListPermissions(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
"name": "User management"
|
"name": "User management"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "User settings"
|
"name": "Current user"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Stock"
|
"name": "Stock"
|
||||||
@@ -1153,11 +1153,44 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/user": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Returns the currently authenticated user",
|
||||||
|
"tags": [
|
||||||
|
"Current user"
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A user object",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/UserDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "The operation was not successful",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/Error400"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/user/settings": {
|
"/user/settings": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Returns all settings of the currently logged in user",
|
"summary": "Returns all settings of the currently logged in user",
|
||||||
"tags": [
|
"tags": [
|
||||||
"User settings"
|
"Current user"
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -1188,7 +1221,7 @@
|
|||||||
"get": {
|
"get": {
|
||||||
"summary": "Returns the given setting of the currently logged in user",
|
"summary": "Returns the given setting of the currently logged in user",
|
||||||
"tags": [
|
"tags": [
|
||||||
"User settings"
|
"Current user"
|
||||||
],
|
],
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@@ -1227,7 +1260,7 @@
|
|||||||
"put": {
|
"put": {
|
||||||
"summary": "Sets the given setting of the currently logged in user",
|
"summary": "Sets the given setting of the currently logged in user",
|
||||||
"tags": [
|
"tags": [
|
||||||
"User settings"
|
"Current user"
|
||||||
],
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"description": "A valid UserSetting object",
|
"description": "A valid UserSetting object",
|
||||||
|
@@ -171,6 +171,7 @@ $app->group('/api', function (RouteCollectorProxy $group) {
|
|||||||
$group->put('/users/{userId}/permissions', '\Grocy\Controllers\UsersApiController:SetPermissions');
|
$group->put('/users/{userId}/permissions', '\Grocy\Controllers\UsersApiController:SetPermissions');
|
||||||
|
|
||||||
// User
|
// User
|
||||||
|
$group->get('/user', '\Grocy\Controllers\UsersApiController:CurrentUser');
|
||||||
$group->get('/user/settings', '\Grocy\Controllers\UsersApiController:GetUserSettings');
|
$group->get('/user/settings', '\Grocy\Controllers\UsersApiController:GetUserSettings');
|
||||||
$group->get('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:GetUserSetting');
|
$group->get('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:GetUserSetting');
|
||||||
$group->put('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:SetUserSetting');
|
$group->put('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:SetUserSetting');
|
||||||
|
Reference in New Issue
Block a user