Show only API-Keys for current user

This commit is contained in:
fipwmaqzufheoxq92ebc 2020-09-02 11:08:48 +02:00
parent 308f10f738
commit 1546a823c5
No known key found for this signature in database
GPG Key ID: F4DF989490C2ADB7

View File

@ -2,12 +2,17 @@
namespace Grocy\Controllers;
use Grocy\Controllers\Users\User;
class OpenApiController extends BaseApiController
{
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
{
$apiKeys = $this->getDatabase()->api_keys();
if(!User::hasPermissions(User::PERMISSION_ADMIN))
$apiKeys = $apiKeys->where('user_id', GROCY_USER_ID);
return $this->renderPage($response, 'manageapikeys', [
'apiKeys' => $this->getDatabase()->api_keys(),
'apiKeys' =>$apiKeys,
'users' => $this->getDatabase()->users()
]);
}