Skip to content

Commit

Permalink
feat: Add more error response messages
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Jul 12, 2024
1 parent aacf2c9 commit 13e0471
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,16 @@ public function get(string $userId): DataResponse {
public function transfer(string $guestUserId, string $targetUserId): DataResponse {
$author = $this->userSession->getUser();
if (!($author instanceof IUser)) {
return new DataResponse([], Http::STATUS_UNAUTHORIZED);
return new DataResponse([
'message' => $this->l10n->t('Failed to authorize')
], Http::STATUS_UNAUTHORIZED);
}

$sourceUser = $this->userManager->get($guestUserId);
if (!($sourceUser instanceof IUser)) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
return new DataResponse([
'message' => $this->l10n->t('Guest does not exist')
], Http::STATUS_NOT_FOUND);
}

if ($this->userManager->userExists($targetUserId)) {
Expand Down

0 comments on commit 13e0471

Please sign in to comment.