Commit 7ee0eac9 authored by quentin.vrel's avatar quentin.vrel

tp4 modification du put

parent 457ca2c9
...@@ -40,4 +40,4 @@ Certaines requêtes sont protégées par un token d'authentification afin de pro ...@@ -40,4 +40,4 @@ Certaines requêtes sont protégées par un token d'authentification afin de pro
|Obtention d'un token|POST|```/login```|'login', 'pwd'(mot de passe haché)|non| |Obtention d'un token|POST|```/login```|'login', 'pwd'(mot de passe haché)|non|
|Liste et informations des utilisateurs|GET|```/user```||non| |Liste et informations des utilisateurs|GET|```/user```||non|
|Informations d'un utilisateur|GET|```/user/<id>```||non| |Informations d'un utilisateur|GET|```/user/<id>```||non|
|Modification de l'email d'un utilisateur|PUT|```/user```|'id', 'mail'|oui| |Modification de l'email d'un utilisateur|PUT|```/user/<id>```|'mail'|oui|
\ No newline at end of file \ No newline at end of file
...@@ -24,8 +24,8 @@ class UserController extends Controller { ...@@ -24,8 +24,8 @@ class UserController extends Controller {
return $this->getAllUsers(); return $this->getAllUsers();
break; break;
case 'PUT': case 'PUT':
return $this->updateUser($this->request->getData()); if ($this->request->getUriParams())
return $this->updateUser(array_merge($this->request->getData(),['id'=>$this->request->getUriParams()[0]]));
break; break;
} }
return Response::errorResponse("unsupported parameters or method in users"); return Response::errorResponse("unsupported parameters or method in users");
...@@ -47,6 +47,7 @@ class UserController extends Controller { ...@@ -47,6 +47,7 @@ class UserController extends Controller {
} }
protected function updateUser($array){ protected function updateUser($array){
try { try {
//var_dump($array);die;
$jwt_token = $this->request->getJwtToken(); $jwt_token = $this->request->getJwtToken();
// echo "jwt = $jwt_token"; // echo "jwt = $jwt_token";
$decodedJWT = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256')); $decodedJWT = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256'));
......
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