Commit 3f5a8a8c authored by raphael.peim's avatar raphael.peim

Finish backend tp4

parent 3f469b49
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
return new Response(400, $message); return new Response(400, $message);
} }
public static function unauthorizedResponse($message = "")
{
return new Response(401, $message);
}
public static function notFoundResponse($message = "") public static function notFoundResponse($message = "")
{ {
return new Response(404, $message); return new Response(404, $message);
......
...@@ -74,33 +74,22 @@ ...@@ -74,33 +74,22 @@
protected function updateUser($put, $id) { protected function updateUser($put, $id) {
$user = User::getWithId($id); $user = User::getWithId($id);
// var_dump(Request::getCurrentRequest()); if (!empty($put) && !empty($user)) {
$jwt_token = $this->request->getJwtToken();
// if (!empty($put) && !empty($user)) { $jwt = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256'));
// try {
// $jwt_token = $this->request->getJwtToken(); if ($jwt->data->id == $id) {
// $decodedJWT = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256')); User::update($put, $id);
$response = Response::okResponse("Utilisateur modifié");
// var_dump($decodedJWT->data); return $response;
// } }
// catch (Exception $e){ else {
// header('WWW-Authenticate: Bearer realm="' . JWT_ISSUER . '"'); return Response::unauthorizedResponse("Modification non autorisée");
}
// $jsonResult = json_encode(array( }
// "message" => "Access denied.", else {
// "error" => $e->getMessage() return Response::notFoundResponse("Aucun utilisateur modifié");
// )); }
// return Response::unauthorizedResponse($jsonResult);
// }
// }
// else {
// return Response::notFoundResponse("Aucun utilisateur modifié");
// }
// User::update($put, $id);
// $response = Response::okResponse("Utilisateur modifié");
// return $response;
} }
protected function deleteUser($id) { protected function deleteUser($id) {
......
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
<i class="fas fa-angle-up"></i> <i class="fas fa-angle-up"></i>
</a> </a>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -46,10 +46,6 @@ ...@@ -46,10 +46,6 @@
<i class="fas fa-angle-up"></i> <i class="fas fa-angle-up"></i>
</a> </a>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -53,10 +53,6 @@ ...@@ -53,10 +53,6 @@
<i class="fas fa-angle-up"></i> <i class="fas fa-angle-up"></i>
</a> </a>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
<?php
$page = explode('.php', end(explode('/', $_SERVER['REQUEST_URI'])))[0];
$page = $page == "" ? "index" : $page;
?>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<span class="icon text-white-50"> <span class="icon text-white-50">
<i class="fas fa-book-open"></i> <i class="fas fa-book-open"></i>
</span> </span>
<!-- <span class="text">Découvrez le mahjong</span> -->
<span class="text">Découvrez le mahjong</span> <span class="text">Découvrez le mahjong</span>
</a> </a>
<a href="login.php" class="btn btn-primary btn-icon-split btn-lg" style="display: flex;"> <a href="login.php" class="btn btn-primary btn-icon-split btn-lg" style="display: flex;">
...@@ -43,10 +44,6 @@ ...@@ -43,10 +44,6 @@
<i class="fas fa-angle-up"></i> <i class="fas fa-angle-up"></i>
</a> </a>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
<?php
phpinfo();
?>
\ No newline at end of file
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<script <?php echo "src=\"js/$page.js\"" ?>></script>
\ No newline at end of file
console.log("Hey !");
\ No newline at end of file
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
<hr> <hr>
</form> </form>
<div class="text-center"> <div class="text-center">
<a class="small" href="register.php">Créer un compte</a> <a class="small" href="signup.php">Créer un compte</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -41,9 +41,6 @@ ...@@ -41,9 +41,6 @@
</div> </div>
</div> </div>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -32,10 +32,6 @@ ...@@ -32,10 +32,6 @@
<i class="fas fa-angle-up"></i> <i class="fas fa-angle-up"></i>
</a> </a>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -53,9 +53,6 @@ ...@@ -53,9 +53,6 @@
</div> </div>
</div> </div>
<script src="vendor/jquery/jquery.js"></script> <?php require_once('js.php'); ?>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
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