From 2e000492ced0979ee69ebe18bde95b2692fc40ca Mon Sep 17 00:00:00 2001 From: dartcafe Date: Fri, 9 Apr 2021 02:14:58 +0200 Subject: [PATCH] username as search parameter #1517 Signed-off-by: dartcafe --- lib/Helper/Trace.php | 54 +++++++++++++++++++++++++++++++++++ lib/Service/SystemService.php | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 lib/Helper/Trace.php diff --git a/lib/Helper/Trace.php b/lib/Helper/Trace.php new file mode 100644 index 000000000..c8cfbea0e --- /dev/null +++ b/lib/Helper/Trace.php @@ -0,0 +1,54 @@ + + * + * @author René Gieling + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Polls\Model; + +class Trace implements \JsonSerializable { + + /** @var Array */ + protected $result = []; + + /** @var string */ + protected $method; + + public function __construct( + string $method, + string $payload = '' + ) { + $this->method = $method; + $this->log('Initialization', $payload); + } + + public function log($operation, $payload = '') { + $this->result[] = [ + 'method' => $this->method, + 'time' => time(), + 'operation' => $operation, + 'payload' => $payload + ]; + } + + public function jsonSerialize(): array { + return $this->result; + } +} diff --git a/lib/Service/SystemService.php b/lib/Service/SystemService.php index cd5657da0..41c705421 100644 --- a/lib/Service/SystemService.php +++ b/lib/Service/SystemService.php @@ -141,7 +141,7 @@ class SystemService { } // get all users - foreach (User::search() as $user) { + foreach (User::search($userName) as $user) { if ($userName === strtolower(trim($user->getId())) || $userName === strtolower(trim($user->getDisplayName()))) { throw new InvalidUsernameException;