f7cloud_client/apps/whiteboard/lib/Service/Authentication/GetSessionUserFromIdService.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

37 lines
863 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Whiteboard\Service\Authentication;
use OCA\Whiteboard\Exception\UnauthorizedException;
use OCA\Whiteboard\Model\AuthenticatedUser;
use OCA\Whiteboard\Model\User;
use OCP\IUserManager;
use OCP\IUserSession;
final class GetSessionUserFromIdService implements GetUserFromIdService {
public function __construct(
private IUserManager $userManager,
private IUserSession $userSession,
private string $userId,
) {
}
#[\Override]
public function getUser(): User {
$user = $this->userManager->get($this->userId);
if (!$user) {
throw new UnauthorizedException('User not found');
}
$this->userSession->setVolatileActiveUser($user);
return new AuthenticatedUser($user);
}
}