user auth, settings, profile

This commit is contained in:
root
2025-12-22 18:01:26 -05:00
parent 81822498c8
commit d19bd16210
19 changed files with 711 additions and 467 deletions

View File

@@ -13,46 +13,47 @@ class UserSettingsController extends ControllerAbstract
{
public function __construct(
private readonly SessionTenant $tenantIdentity,
private readonly SessionIdentity $userIdentity,
private readonly SessionIdentity $userIdentity,
private readonly UserService $userService
) {}
/**
* retrieve user settings
* Retrieve user settings
* If no specific settings are requested, all settings are returned
*
* @param array $settings list of settings to retrieve
*
* @example request body:
* {
* "settings": ["key1", "key2"]
* }
* @return JsonResponse Settings data as key-value pairs
*/
#[AuthenticatedRoute('/user/settings/read', name: 'user.settings.read', methods: ['PUT', 'PATCH'])]
public function read(array $settings = []): JsonResponse
#[AuthenticatedRoute('/user/settings', name: 'user.settings.read', methods: ['GET'])]
public function read(): JsonResponse
{
// authorize request
$tenantId = $this->tenantIdentity->identifier();
$userId = $this->userIdentity->identifier();
// Fetch all settings
$settings = $this->userService->fetchSettings([]);
return $this->userService->fetchSettings($tenantId, $userId, $settings);
return new JsonResponse($settings, JsonResponse::HTTP_OK);
}
/**
* store user settings
* Update user settings
*
* @param array $settings key-value pairs of settings to store
* @param array $settings Key-value pairs of settings to update
*
* @example request body:
* {
* "key1": "value1",
* "key2": "value2"
* "theme": "dark",
* "language": "en",
* "notifications": true
* }
*
* @return JsonResponse Updated settings data
*/
#[AuthenticatedRoute('/user/settings/write', name: 'user.settings.write', methods: ['PUT', 'PATCH'])]
public function write(array $settings): JsonResponse
#[AuthenticatedRoute('/user/settings', name: 'user.settings.update', methods: ['PUT', 'PATCH'])]
public function update(array $settings = []): JsonResponse
{
return new JsonResponse(['status' => 'not_implemented'], JsonResponse::HTTP_NOT_IMPLEMENTED);
$this->userService->storeSettings($settings);
// Return updated settings
$updatedSettings = $this->userService->fetchSettings(array_keys($settings));
return new JsonResponse($updatedSettings, JsonResponse::HTTP_OK);
}
}