mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Added an API endpoint to get the authenticated user (closes #1165)
This commit is contained in:
parent
fda8411ab3
commit
48aa9fd138
@ -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-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 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`)
|
||||
- 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
|
||||
|
@ -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)
|
||||
{
|
||||
try
|
||||
|
@ -26,7 +26,7 @@
|
||||
"name": "User management"
|
||||
},
|
||||
{
|
||||
"name": "User settings"
|
||||
"name": "Current user"
|
||||
},
|
||||
{
|
||||
"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": {
|
||||
"get": {
|
||||
"summary": "Returns all settings of the currently logged in user",
|
||||
"tags": [
|
||||
"User settings"
|
||||
"Current user"
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
@ -1188,7 +1221,7 @@
|
||||
"get": {
|
||||
"summary": "Returns the given setting of the currently logged in user",
|
||||
"tags": [
|
||||
"User settings"
|
||||
"Current user"
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
@ -1227,7 +1260,7 @@
|
||||
"put": {
|
||||
"summary": "Sets the given setting of the currently logged in user",
|
||||
"tags": [
|
||||
"User settings"
|
||||
"Current user"
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "A valid UserSetting object",
|
||||
|
@ -171,6 +171,7 @@ $app->group('/api', function (RouteCollectorProxy $group) {
|
||||
$group->put('/users/{userId}/permissions', '\Grocy\Controllers\UsersApiController:SetPermissions');
|
||||
|
||||
// User
|
||||
$group->get('/user', '\Grocy\Controllers\UsersApiController:CurrentUser');
|
||||
$group->get('/user/settings', '\Grocy\Controllers\UsersApiController:GetUserSettings');
|
||||
$group->get('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:GetUserSetting');
|
||||
$group->put('/user/settings/{settingKey}', '\Grocy\Controllers\UsersApiController:SetUserSetting');
|
||||
|
Loading…
x
Reference in New Issue
Block a user