@@ -160,6 +160,39 @@ protected function curateUpdatePayload(array $payload): array
160160 ]);
161161 }
162162
163+ private function _create (){
164+ try {
165+
166+ if (!Request::isJson ()) return $ this ->error400 ();
167+
168+ $ payload = Request::json ()->all ();
169+ // Creates a Validator instance and validates the data.
170+ $ validation = Validator::make ($ payload , UserValidationRulesFactory::build ($ payload ));
171+ if ($ validation ->fails ()) {
172+ $ ex = new ValidationException ();
173+ throw $ ex ->setMessages ($ validation ->messages ()->toArray ());
174+ }
175+
176+ $ user = $ this ->openid_user_service ->create ($ payload );
177+
178+ return $ this ->created (SerializerRegistry::getInstance ()->getSerializer ($ user , SerializerRegistry::SerializerType_Private)->serialize ());
179+ }
180+ catch (ValidationException $ ex1 )
181+ {
182+ Log::warning ($ ex1 );
183+ return $ this ->error412 ($ ex1 ->getMessages ());
184+ }
185+ catch (EntityNotFoundException $ ex2 )
186+ {
187+ Log::warning ($ ex2 );
188+ return $ this ->error404 (['message ' => $ ex2 ->getMessage ()]);
189+ }
190+ catch (Exception $ ex ) {
191+ Log::error ($ ex );
192+ return $ this ->error500 ($ ex );
193+ }
194+ }
195+
163196 private function _update ($ id ){
164197 try {
165198
@@ -193,6 +226,10 @@ private function _update($id){
193226 }
194227 }
195228
229+ public function create (){
230+ return $ this ->_create ();
231+ }
232+
196233 public function updateMe (){
197234 return $ this ->_update ($ this ->resource_server_context ->getCurrentUserId ());
198235 }
0 commit comments