aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/ApiBundle/Controller/UserRestController.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php
index a1d7c1ff..8f675b8d 100644
--- a/src/Wallabag/ApiBundle/Controller/UserRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php
@@ -46,7 +46,9 @@ class UserRestController extends WallabagRestController
46 if (!$this->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) { 46 if (!$this->getParameter('fosuser_registration') || !$this->get('craue_config')->get('api_user_registration')) {
47 $json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json'); 47 $json = $this->get('serializer')->serialize(['error' => "Server doesn't allow registrations"], 'json');
48 48
49 return (new JsonResponse())->setJson($json)->setStatusCode(403); 49 return (new JsonResponse())
50 ->setJson($json)
51 ->setStatusCode(JsonResponse::HTTP_FORBIDDEN);
50 } 52 }
51 53
52 $userManager = $this->get('fos_user.user_manager'); 54 $userManager = $this->get('fos_user.user_manager');
@@ -90,7 +92,9 @@ class UserRestController extends WallabagRestController
90 92
91 $json = $this->get('serializer')->serialize(['error' => $errors], 'json'); 93 $json = $this->get('serializer')->serialize(['error' => $errors], 'json');
92 94
93 return (new JsonResponse())->setJson($json)->setStatusCode(400); 95 return (new JsonResponse())
96 ->setJson($json)
97 ->setStatusCode(JsonResponse::HTTP_BAD_REQUEST);
94 } 98 }
95 99
96 $userManager->updateUser($user); 100 $userManager->updateUser($user);
@@ -99,17 +103,18 @@ class UserRestController extends WallabagRestController
99 $event = new UserEvent($user, $request); 103 $event = new UserEvent($user, $request);
100 $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event); 104 $this->get('event_dispatcher')->dispatch(FOSUserEvents::USER_CREATED, $event);
101 105
102 return $this->sendUser($user); 106 return $this->sendUser($user, JsonResponse::HTTP_CREATED);
103 } 107 }
104 108
105 /** 109 /**
106 * Send user response. 110 * Send user response.
107 * 111 *
108 * @param User $user 112 * @param User $user
113 * @param int $status HTTP Status code to send
109 * 114 *
110 * @return JsonResponse 115 * @return JsonResponse
111 */ 116 */
112 private function sendUser(User $user) 117 private function sendUser(User $user, $status = JsonResponse::HTTP_OK)
113 { 118 {
114 $json = $this->get('serializer')->serialize( 119 $json = $this->get('serializer')->serialize(
115 $user, 120 $user,
@@ -117,7 +122,9 @@ class UserRestController extends WallabagRestController
117 SerializationContext::create()->setGroups(['user_api']) 122 SerializationContext::create()->setGroups(['user_api'])
118 ); 123 );
119 124
120 return (new JsonResponse())->setJson($json); 125 return (new JsonResponse())
126 ->setJson($json)
127 ->setStatusCode($status);
121 } 128 }
122 129
123 /** 130 /**