Commit ac9b3ed1 authored by Zohten's avatar Zohten

small changes for preparing refactoring

parent dcfb57f3
......@@ -44,7 +44,7 @@ class UserController extends Controller
protected function getAllUsers()
{
$users = User::getList();
$response = Response::okResponse(json_encode($users));
$response = Response::okResponse(json_encode($users, JSON_PRETTY_PRINT));
return $response;
}
......@@ -70,12 +70,6 @@ class UserController extends Controller
try {
$jwt_token = $this->request->getJwtToken();
$decodedJWT = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256'));
if ($decodedJWT->data->id != $array['id']) {
throw new Exception("You don't have access to this account.", 1);
}
User::updateUser($array);
} catch (Exception $e) {
header('WWW-Authenticate: Bearer realm="'.JWT_ISSUER.'"');
......@@ -85,6 +79,11 @@ class UserController extends Controller
));
return Response::unauthorizedResponse($jsonResult);
}
if ($decodedJWT->data->id != $array['id']) {
return Response::unauthorizedResponse("You don't have access to this account.");
}
User::updateUser($array);
$response = Response::okResponse('User succesfully updated !');
return $response;
}
......
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