Commit 344fc7b0 authored by thibaut-felten's avatar thibaut-felten

Doc + Security

parent b7301862
......@@ -47,14 +47,22 @@ class UserController extends Controller {
protected function getUser($id)
{
$user = User::getUserById($id);
$response = new Response(200,json_encode($user));
if($user == Array()){
$response = Response::errorInParametersResponse("User not found");
}else{
$response = new Response(200,json_encode($user));
}
return $response;
}
protected function deleteUser($id){
User::deleteUser($id);
$response = Response::okResponse("User deleted");
$user = User::getUserById($id);
if($user == Array()){
$response = Response::errorInParametersResponse("User not found");
}else{
User::deleteUser($id);
$response = Response::okResponse("User deleted");
}
return $response;
}
......@@ -113,8 +121,13 @@ class UserController extends Controller {
protected function createUser($data)
{
$user = User::createUser(array( "login" => $data['USER_LOGIN'], "password" => $data['USER_PASSWORD'], "role" => $data['USER_ROLE'], "email" => $data['USER_EMAIL'],"lastname" => $data['USER_LASTNAME'],"firstname" => $data['USER_FIRSTNAME']));
$response = new Response(200,json_encode($user));
if(array_key_exists("USER_LOGIN", $data) && array_key_exists("USER_PASSWORD", $data) && array_key_exists("USER_ROLE", $data) && array_key_exists("USER_EMAIL", $data) && array_key_exists("USER_LASTNAME", $data) && array_key_exists("USER_FIRSTNAME", $data)){
$user = User::createUser(array( "login" => $data['USER_LOGIN'], "password" => $data['USER_PASSWORD'], "role" => $data['USER_ROLE'], "email" => $data['USER_EMAIL'],"lastname" => $data['USER_LASTNAME'],"firstname" => $data['USER_FIRSTNAME']));
$response = new Response(200,json_encode($user));
}else{
$response = Response::errorInParametersResponse("Parameters missing");
}
return $response;
}
}
......@@ -16,3 +16,13 @@ Used to delete a user account.
**Content example**
`"User deleted"`
## Error Response
### Mauvais id
**Code** : `400 Bad Request`
**Content example**
`"User not found"`
......@@ -26,3 +26,13 @@ Used to retrieve the information of one user
"USER_ROLE": "1"
}
```
## Error Response
### Mauvais identifiant
**Code** : `400 Bad Request`
**Content example**
`"User not found"`
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment