impement and fix user settings
This commit is contained in:
@@ -36,24 +36,26 @@ class UserProfileController extends ControllerAbstract
|
||||
* Update user profile fields
|
||||
* Only editable fields can be updated. Provider-managed fields are automatically filtered out.
|
||||
*
|
||||
* @param array $profile Key-value pairs of profile fields to update
|
||||
* @param array $data Key-value pairs of profile fields to update
|
||||
*
|
||||
* @example request body:
|
||||
* {
|
||||
* "name_given": "John",
|
||||
* "name_family": "Doe",
|
||||
* "phone": "+1234567890"
|
||||
* "data": {
|
||||
* "name_given": "John",
|
||||
* "name_family": "Doe",
|
||||
* "phone": "+1234567890"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @return JsonResponse Updated profile data
|
||||
*/
|
||||
#[AuthenticatedRoute('/user/profile', name: 'user.profile.update', methods: ['PUT', 'PATCH'])]
|
||||
public function update(array $profile = []): JsonResponse
|
||||
public function update(array $data): JsonResponse
|
||||
{
|
||||
$userId = $this->userIdentity->identifier();
|
||||
|
||||
// storeProfile automatically filters out provider-managed fields
|
||||
$this->userService->storeProfile($userId, $profile);
|
||||
$this->userService->storeProfile($userId, $data);
|
||||
|
||||
// Return updated profile
|
||||
$updatedProfile = $this->userService->fetchProfile($userId);
|
||||
|
||||
@@ -26,8 +26,8 @@ class UserSettingsController extends ControllerAbstract
|
||||
#[AuthenticatedRoute('/user/settings', name: 'user.settings.read', methods: ['GET'])]
|
||||
public function read(): JsonResponse
|
||||
{
|
||||
// Fetch all settings
|
||||
$settings = $this->userService->fetchSettings([]);
|
||||
// Fetch all settings (no filter)
|
||||
$settings = $this->userService->fetchSettings();
|
||||
|
||||
return new JsonResponse($settings, JsonResponse::HTTP_OK);
|
||||
}
|
||||
@@ -35,24 +35,26 @@ class UserSettingsController extends ControllerAbstract
|
||||
/**
|
||||
* Update user settings
|
||||
*
|
||||
* @param array $settings Key-value pairs of settings to update
|
||||
* @param array $data Key-value pairs of settings to update
|
||||
*
|
||||
* @example request body:
|
||||
* {
|
||||
* "theme": "dark",
|
||||
* "language": "en",
|
||||
* "notifications": true
|
||||
* "data": {
|
||||
* "theme": "dark",
|
||||
* "language": "en",
|
||||
* "notifications": true
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @return JsonResponse Updated settings data
|
||||
*/
|
||||
#[AuthenticatedRoute('/user/settings', name: 'user.settings.update', methods: ['PUT', 'PATCH'])]
|
||||
public function update(array $settings = []): JsonResponse
|
||||
public function update(array $data): JsonResponse
|
||||
{
|
||||
$this->userService->storeSettings($settings);
|
||||
$this->userService->storeSettings($data);
|
||||
|
||||
// Return updated settings
|
||||
$updatedSettings = $this->userService->fetchSettings(array_keys($settings));
|
||||
$updatedSettings = $this->userService->fetchSettings(array_keys($data));
|
||||
|
||||
return new JsonResponse($updatedSettings, JsonResponse::HTTP_OK);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user